Skip to content

Auth.ApiKey ​

WARNING

This SDK is DEPRECATED

Overview ​

Available Operations ​

getJwtFromKey ​

Exchange an API key for a JWT token

⚠️ DEPRECATED: Use auth.apiKeys.exchangeToken() instead. This method will be removed in a future release.. Use exchangeToken instead.

Example Usage ​

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.auth.apiKey.getJwtFromKey({
    requestBody: {
      audience: "https://my-awesome-website.com",
      externalUserId: "the-user-id-in-your-system",
      permissions: [
        "agent:create",
        "agent:read",
      ],
    },
  });

  console.log(result);
}

run();

Standalone function ​

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { authApiKeyGetJwtFromKey } from "@meetkai/mka1/funcs/authApiKeyGetJwtFromKey.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await authApiKeyGetJwtFromKey(sdk, {
    requestBody: {
      audience: "https://my-awesome-website.com",
      externalUserId: "the-user-id-in-your-system",
      permissions: [
        "agent:create",
        "agent:read",
      ],
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("authApiKeyGetJwtFromKey failed:", res.error);
  }
}

run();

React hooks and utilities ​

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useAuthApiKeyGetJwtFromKeyMutation
} from "@meetkai/mka1/react-query/authApiKeyGetJwtFromKey.js";

Parameters ​

ParameterTypeRequiredDescription
requestoperations.GetJwtFromKeyRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response ​

Promise<operations.GetJwtFromKeyResponseBody>

Errors ​

Error TypeStatus CodeContent Type
errors.GetJwtFromKeyResponseBody400application/json
errors.GetJwtFromKeyAuthApiKeyResponseBody401application/json
errors.GetJwtFromKeyAuthApiKeyResponseResponseBody500application/json
errors.APIError4XX, 5XX*/*