question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid Id Token Errors when manually setting android device time forward

See original GitHub issue

Configuration

  • Version: 0.9.1
  • Integration: Kotlin
  • Identity provider: Comcast

Description

We recently upgraded from 0.7.1 to 0.9.1 and went to prod without issue. We found now that if we set an android’s clock forward an hour (disable auto time/timezone) our app throws


    AuthorizationException: {"type":0,"code":9,"errorDescription":"Invalid ID Token"}
        at net.openid.appauth.IdToken.validate(IdToken.java:182)
        at net.openid.appauth.AuthorizationService$TokenRequestTask.onPostExecute(AuthorizationService.java:694)
        at net.openid.appauth.AuthorizationService$TokenRequestTask.onPostExecute(AuthorizationService.java:563)
        at android.os.AsyncTask.finish(AsyncTask.java:771)

I see this library doing just that:

        Long nowInSeconds = clock.getCurrentTimeMillis() / MILLIS_PER_SECOND;
        if (nowInSeconds > this.expiration) {
            throw AuthorizationException.fromTemplate(GeneralErrors.ID_TOKEN_VALIDATION_ERROR,
                new IdTokenException("ID Token expired"));
        }

Did something change where I need to tell my Auth Provider what I think the time is so my Id Token is aligned?

My Token Provider would be setting the private static final String KEY_EXPIRATION = "exp";

field in the id token but how would they know my clock was set forward an hour?

It looks like this validation was introduced https://github.com/openid/AppAuth-Android/pull/385/files and I need to disable it. note it says :

  // OpenID Connect Core Section 3.1.3.7. rule #9
        // Validates that the current time is before the expiry time.

but that’s not in https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation Edit: Found related issue https://github.com/openid/AppAuth-Android/issues/693

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
nyihtwe1commented, Aug 27, 2021

I am binngner

0reactions
skauppicommented, Nov 8, 2022

In my opinion client time can be allowed to be out of sync. Resource server will anyway respond with error, if token is invalid/expired.

At least having a parameter to optionally skip the validation of time would be useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practices for FCM registration token management
On this page · Basic best practices. Retrieve and store registration tokens; Detect invalid token responses from the FCM backend · Ensuring registration...
Read more >
Verify the Google ID token on your server side | Authentication
After Google returns an ID token, it's submitted by an HTTP POST method request, with the parameter name credential , to your login...
Read more >
Error: Firebase ID token has expired - Stack Overflow
Error : Firebase ID token has expired. You will get this error when your device time is wrong. Check your device clock time...
Read more >
My app is showing an Authentication error / Invalid ID Token ...
If you receive an Authentication error / Invalid ID Token message when trying to login into your app, you may need to change...
Read more >
SafetyNet Attestation API - Android Developers
If an incorrect version is installed, your app might stop responding after calling the API. If your app detects that an incorrect version...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found