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

GoogleCredentials not working on Android OS 8 and below #1603

Closed
play-yuhei-ueno opened this issue Dec 18, 2024 · 6 comments
Closed

GoogleCredentials not working on Android OS 8 and below #1603

play-yuhei-ueno opened this issue Dec 18, 2024 · 6 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@play-yuhei-ueno
Copy link

Environment details

  1. PlayItegrity
  2. Android OS 8 below
  3. Java version: 1.8
  4. version(s):

Steps to reproduce

Code example's will reproduce it reliably.

Code example

val inputStream = context.assets.open("xxxxxxxxxx.json")
val credentials = GoogleCredentials.fromStream(inputStream)
val scopedCredentials = credentials.createScoped("https://www.googleapis.com/auth/playintegrity")

Stack trace

No stack trace...

External references such as API reference guides

Any additional information below

https://support.google.com/googleplay/android-developer/thread/313885564/googlecredentials-not-working-on-android-os-8-and-below

I've tried posting questions here.
I checked with Firebase, but since it's about Playitegrity, they responded that they want me to check with this community, so I'm asking the question.

@lqiu96 lqiu96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 15, 2025
@lqiu96
Copy link
Contributor

lqiu96 commented Jan 15, 2025

Hey @play-yuhei-ueno, can you provide more details about this issue? A stacktrace or logs would help us diagnose the issue better. We're not certain what went wrong/ what isn't working for you.

Also, the link you provided above may have expired. I am unable to view that link

@play-akira-kawakami
Copy link

Supplemental Information

  • Error Logs: There are no error logs generated, so I cannot provide a stack trace.
  • Error Handling: The issue is not caused by an error being caught in a catch block of a try-catch statement.

Since there are no error logs, I added logging to trace where the issue occurs. Based on the logs, the problematic code is specifically within the val credentials = GoogleCredentials.fromStream(inputStream) statement.

Here is the code I used for debugging:

val inputStream = context.assets.open("xxxxxxxxxx.json")
Log.d(TAG, "inputStream complete")
val credentials = GoogleCredentials.fromStream(inputStream)
Log.d(TAG, "credentials complete")
val scopedCredentials = credentials.createScoped("https://www.googleapis.com/auth/playintegrity")
Log.d(TAG, "scopedCredentials complete")

Below is the log output:
inputStream complete

From these results, I used Network Inspector to investigate what the val credentials = GoogleCredentials.fromStream(inputStream) statement is doing. It attempts to access the following URL to retrieve credentials:
https://oauth2.googleapis.com/token

I suspect that the issue might be related to the access to the above URL. Specifically, it seems like no response is being returned.

@lqiu96
Copy link
Contributor

lqiu96 commented Jan 24, 2025

val credentials = GoogleCredentials.fromStream(inputStream) statement is doing. It attempts to access the following URL to retrieve credentials:

The fromStream() call itself doesn't make a network call to retrieve an access token. The call should only parse the JSON file and attempt to create the *Credential class (I assume from above is a ServiceAccountCredential).

If you need to retrieve the access token, you can call Credential.refreshAccessToken() which will make the network call to the Token URI. The Credentials will automatically attempt to retrieve a valid access token if a client library network call is made (i.e. you're calling a firebase API).

Specifically, it seems like no response is being returned.

I am a bit confused on this. Since no network call from the Credentials should have been made, are you sure this is happening? A repro would be helpful to debug this case (perhaps there is something else going on that I can't explain).

@play-akira-kawakami
Copy link

I tried again and I am having trouble with fromStream() as well.

I am a bit confused on this. since no network call from the Credentials should have been made, are you sure this is happening?

You say you are not calling the network from Credentials, what else do you think is going on? I have no idea other than GoogleCredentials.fromStream() is not supported in Android OS 8 and below.

@lqiu96
Copy link
Contributor

lqiu96 commented Jan 28, 2025

You say you are not calling the network from Credentials, what else do you think is going on?

I would need a repro to be able to investigate. Android is not something that I am familiar with and I would need something reproducible to confirm this is an auth library issue.

GoogleCredentials.fromStream() does nothing but try to parse the JSON file and create the associate *Credentials type:

Assuming that you're using a Service Account, it creates a ServiceAccountCredentials object:

I have no idea other than GoogleCredentials.fromStream() is not supported in Android OS 8 and below.

I have no idea what version of Java that is being used for compatibility with Android OS 8 and below. The Auth Library supports Java 8+

@lqiu96
Copy link
Contributor

lqiu96 commented Feb 11, 2025

Going to close this issue due to inactivity. If there is a repro, stack trace, logs, or any other information that could help us narrow down the possible issue, we can proceed from there and I'll re-open the issue.

@lqiu96 lqiu96 closed this as completed Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 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

3 participants