Pular para o conteúdo principal
POST
/
api
/
v1
/
authentication
/
api-key
/
exchange-token
Python (SDK)
from mka1 import SDK


with SDK(
    bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:

    res = sdk.auth.api_key.get_jwt_from_key(body={
        "audience": "https://my-awesome-website.com",
        "external_user_id": "the-user-id-in-your-system",
        "permissions": [
            "agent:create",
            "agent:read",
        ],
    })

    # Handle response
    print(res)
{
  "token": "the-jwt-token"
}

Autorizações

Authorization
string
header
obrigatório

Gateway auth: send Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, you can also send X-On-Behalf-Of: <external-user-id>.

Cabeçalhos

X-On-Behalf-Of
string

Optional external end-user identifier forwarded by the API gateway.

Corpo

application/json
audience
string<uri>
obrigatório

Reivindicação de público (aud) JWT para o token trocado. Defina isso para a URL da API/serviço de destino que deve aceitar o token.

externalUserId
string
obrigatório

Seu identificador de usuário externo a ser colocado na declaração de sujeito (sub) do JWT. Deve ter de 1 a 150 caracteres ASCII imprimíveis e não pode ser o caractere curinga *.

Required string length: 1 - 150
Pattern: ^[\x20-\x7E]+$
expiresIn
number
padrão:3600

Tempo de vida do token em segundos. Deve estar entre 300 (5 minutos) e 2592000 (30 dias). O padrão é 3600 (1 hora).

Intervalo obrigatório: 300 <= x <= 2592000
permissions
string[]

Conjunto opcional de permissões da chave API a serem incorporadas no token. Se omitido, todas as permissões da chave API serão utilizadas.

Resposta

Chave API trocada com sucesso por um token JWT

token
string
obrigatório

Signed JWT exchange token to use when calling downstream services.