Create
Create an IAM token for the specified identity.
- TypeScript
- Python
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);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.iam.v1.iam_token_service_pb2 import CreateIamTokenRequest
from yandex.cloud.iam.v1.iam_token_service_pb2_grpc import IamTokenServiceStub
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(IamTokenServiceStub)
response = service.Create(
CreateIamTokenRequest(
# yandex_passport_oauth_token = "yandexPassportOauthToken",
# jwt = "jwt"
)
)
print(response)
CreateIamTokenRequest
One of identity
yandexPassportOauthToken
: stringOAuth token for a Yandex account.
For more information, see OAuth token.
jwt
: stringJSON Web Token (JWT) for a service account.
For more information, see Get IAM token for a service account.
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.