Skip to main content

Create

Create an IAM token for the specified identity.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const CreateIamTokenRequest =
cloudApi.iam.iam_token_service.CreateIamTokenRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.IamTokenServiceClient);

const result = await client.create(
CreateIamTokenRequest.fromPartial({
// yandexPassportOauthToken: "yandexPassportOauthToken",
// jwt: "jwt"
})
);
console.log(result);
})();

CreateIamTokenRequest

One of identity

CreateIamTokenResponse

iamToken : string

IAM token for the specified identity.

You should pass the token in the Authorization header for any further API requests. For example, Authorization: Bearer [iam_token].

expiresAt : google.protobuf.Timestamp

IAM token expiration time.