yandex-cloud / go-sdk

Yandex.Cloud Go SDK
MIT License
81 stars 15 forks source link

Can't AUTH --> rpc error: code = Unauthenticated desc = UNAUTHENTICATED: The token is invalid #21

Closed remotejob closed 8 months ago

remotejob commented 8 months ago

ref: examples/lockboxpayload

  1. Service Account "lockbox.admin" named "lockbox"
  2. yc iam access-key create --service-account-name lockbox --description "for view password etc."

    iamToken := flag.String("iam-token", "YCAJEqBE3S6DqXXXXXXX", "YCONuZpADnC3Ue8ZAC_kdJKk9-UdTXXXXXXX") secretID := flag.String("secret-id","e6qh4c0770di1i2emljc", "e6qpndjijfq1ivu41q3t") sdk, err := ycsdk.Build(context.Background(), ycsdk.Config{ Credentials: ycsdk.NewIAMTokenCredentials(*iamToken), }) if err != nil { log.Println("1") log.Fatal(err) }

nikolaymatrosov commented 8 months ago

Based on the format of the secret strings you’re using, it seems you are employing the wrong type of secret. It appears that you are using Static access keys compatible with the AWS API, but the example expects an IAM token. Additionally, you are misusing flag.String. This function defines a flag to be parsed from the application call in the terminal; you should not directly insert values into the flag.String arguments.

remotejob commented 8 months ago

Thank!