Crear un rol personalizado
Requiere un propietario u administrador humano actual de la organización, además de write:org para tokens OAuth y claves de API. Las cuentas de servicio son rechazadas, incluidas las administrativas. Las escrituras desde el navegador requieren una sesión activa sin caché y un Origin de confianza. Un rol es un nombre y un conjunto de ámbitos. El nombre tiene de 1 a 64 caracteres después de la normalización Unicode NFKC, no tiene coma ni caracteres de control o invisibles, es único en la organización sin distinguir mayúsculas y minúsculas, y no puede ser owner, admin ni member. Cada ámbito debe estar en supportedScopes; cualquier otro ámbito devuelve 400 ROLE_SCOPES_UNSUPPORTED. Un nombre ya usado devuelve 409 ROLE_NAME_TAKEN, y el rol 101 devuelve 409 ROLE_LIMIT_REACHED.
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK();
var res = await sdk.Auth.Orgs.CreateRoleAsync(
security: new CreateOrgRoleSecurity() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
},
orgId: "<id>",
body: new CreateOrgRoleRequestBody() {
Name = "<value>",
Scopes = new List<string>() {
"<value 1>",
"<value 2>",
"<value 3>",
},
}
);
// handle responsefrom meetkai_mka1 import SDK, models
with SDK() as sdk:
res = sdk.auth.orgs.create_role(security=models.CreateOrgRoleSecurity(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
), org_id="<id>", name="<value>", scopes=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK();
async function run() {
const result = await sdk.auth.orgs.createRole({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
}, {
orgId: "<id>",
requestBody: {
name: "<value>",
scopes: [
"<value 1>",
"<value 2>",
"<value 3>",
],
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New()
res, err := s.Auth.Orgs.CreateRole(ctx, operations.CreateOrgRoleSecurity{
BearerAuth: mka1.Pointer("<YOUR_BEARER_TOKEN_HERE>"),
}, "<id>", operations.CreateOrgRoleRequestBody{
Name: "<value>",
Scopes: []string{
"<value 1>",
"<value 2>",
"<value 3>",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', scopes: ['<string>']})
};
fetch('https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'scopes' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"role": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"scopes": [
"<string>"
],
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Autorizaciones
Cuerpo
¿Esta página le ayudó?
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK();
var res = await sdk.Auth.Orgs.CreateRoleAsync(
security: new CreateOrgRoleSecurity() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
},
orgId: "<id>",
body: new CreateOrgRoleRequestBody() {
Name = "<value>",
Scopes = new List<string>() {
"<value 1>",
"<value 2>",
"<value 3>",
},
}
);
// handle responsefrom meetkai_mka1 import SDK, models
with SDK() as sdk:
res = sdk.auth.orgs.create_role(security=models.CreateOrgRoleSecurity(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
), org_id="<id>", name="<value>", scopes=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK();
async function run() {
const result = await sdk.auth.orgs.createRole({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
}, {
orgId: "<id>",
requestBody: {
name: "<value>",
scopes: [
"<value 1>",
"<value 2>",
"<value 3>",
],
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New()
res, err := s.Auth.Orgs.CreateRole(ctx, operations.CreateOrgRoleSecurity{
BearerAuth: mka1.Pointer("<YOUR_BEARER_TOKEN_HERE>"),
}, "<id>", operations.CreateOrgRoleRequestBody{
Name: "<value>",
Scopes: []string{
"<value 1>",
"<value 2>",
"<value 3>",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', scopes: ['<string>']})
};
fetch('https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'scopes' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"role": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"scopes": [
"<string>"
],
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}