Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TopicAdminClient UnauthenticatedException When Settings Endpoints #333

Closed
benshriki opened this issue Feb 16, 2023 · 1 comment
Closed

Comments

@benshriki
Copy link

Hi,
I've found an issue when settings TopicAdminClient with endpoint.

Current behavior:

  • When i try to set TopicAdminClient with credentials out of a json(String) and endpoint different then the global "pubsub.googleapis.com" end point i get an UnauthenticatedException.
  • When i use ADC authentication and set the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to a json file with the same content i can set to all endpoints with no errors.
  • When i try to set TopicAdminClient with credentials out of a json(String) and use the global endpoint pubsub.googleapis.com" i get no errors.

Expected behavior:
To be able to use both authentication ways and set any endpoint without encountering any error.

Example:

...
ServiceAccountCredentials cred = ServiceAccountCredentials
              .fromStream(new ByteArrayInputStream(jsonCredentials.getBytes()));  // json as String

CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(cred); 

TopicAdminSettings topicAdminSettings = TopicAdminSettings.newBuilder()
                                 .setCredentialsProvider(credentialsProvider)   // credentials out of given json file
                                 .setEndpoint(endpoint)                         // endpoint different then global endpoint
                                 .build();

TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings);

topicAdminClient.getTopic(someTopic);

the code above produce the following exception:
com.google.api.gax.rpc.UnauthenticatedException: io.grpc.StatusRuntimeException: UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.'

@kamalaboulhosn
Copy link
Collaborator

This issue should be in the Java library repo, so I have created it there: googleapis/java-pubsub#1480.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants