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 #1480

Closed
kamalaboulhosn opened this issue Feb 16, 2023 · 4 comments
Closed
Assignees
Labels
api: pubsub Issues related to the googleapis/java-pubsub API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@kamalaboulhosn
Copy link
Contributor

From GoogleCloudPlatform/pubsub#333:

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.'

@ozac
Copy link

ozac commented Mar 1, 2023

@SimonScholz , how is this PR related to the issue?

@SimonScholz
Copy link

SimonScholz commented Mar 1, 2023

@SimonScholz , how is this PR related to the issue?

Sorry @ozac I just corrected the reference. It is not related to this, but to #1504
I guess the auto completion of GitHub lead me to choose the wrong reference.

@maitrimangal maitrimangal added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jun 12, 2023
@kamalaboulhosn
Copy link
Contributor Author

@benshriki Can you please provide the exact string used for the endpoint?

@hongalex
Copy link
Member

hongalex commented Dec 7, 2023

Closing since there hasn't been a response from the original issue opener in a while. If you're still having issues, please comment below and we'll reopen this.

@hongalex hongalex closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/java-pubsub API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants