yandex-cloud/go-sdk

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

Closed this issue · 2 comments

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)
    }

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.

Thank!