iam_token.go raw
1 package credentials
2
3 import (
4 "context"
5 )
6
7 var _ NonExchangeableCredentials = (*IAMTokenCredentials)(nil)
8
9 // IAMTokenCredentials implements Credentials with IAM token as-is
10 // Read more on https://yandex.cloud/en-ru/docs/iam/concepts/authorization/iam-token
11 type IAMTokenCredentials struct {
12 iamToken string
13 }
14
15 func (creds *IAMTokenCredentials) YandexCloudAPICredentials() {}
16
17 func (creds *IAMTokenCredentials) IAMToken(ctx context.Context) (*CredentialsToken, error) {
18 return &CredentialsToken{Token: creds.iamToken}, nil
19 }
20
21 func IAMToken(iamToken string) NonExchangeableCredentials {
22 return &IAMTokenCredentials{
23 iamToken: iamToken,
24 }
25 }
26