Closed pkk-code closed 8 months ago
Hi @pkk-code, sorry for the delay. What environment are you on and do you know what kind of credentials are being used?
Closing this due to lack of response. Please open another issue if you are still having authentication difficulties.
Client
storage
Environment
Any
Go Environment
G0 1.21
Code Access token is generated from this code and passed to different module to authenticate.
Module 1: credentials, err := google.FindDefaultCredentials(ctx, scopes...) if err == nil { token, err = credentials.TokenSource.Token() if err != nil { log.Print(err) } }
Module 2: token.AccessToken from module1 is used to initialize the storage client .
Expected behavior
Authenticated client that lists the buckets in the project
Actual behavior
googleapi: Error 401: Invalid Credentials, authError
Additional context
The identical concept functions correctly when using the Java SDK but encounters issues with the Go SDK, potentially due to configuration omissions within the code i listed above or in Go SDK. Could you please check this?
String accessTokenString = "token"; var accessToken = AccessToken.newBuilder().setTokenValue(accessTokenString).build(); var cred = OAuth2CredentialsWithRefresh.create(accessToken); Storage storageAccessToken = StorageOptions.newBuilder().setCredentials(cred).setProjectId("projectid").build().getService(); var list = storageAccessToken.list("bucket"); list.getValues().forEach(val -> { System.out.println(val.asBlobInfo().getName()); });