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

plugin doesn't handle expired tokens #29

Closed
yetanotherspinner opened this issue Oct 16, 2019 · 4 comments
Closed

plugin doesn't handle expired tokens #29

yetanotherspinner opened this issue Oct 16, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@yetanotherspinner
Copy link

I am using google login and it seems the plugin doesn't handle a scenario when application was signed in, but the token has expired already (it is valid for 1 hour). I had to add the following branch to GoogleProviderHandler.java (to "public bool isAuthenticated()"):

        if (account != null)
        {
            String  token = account.getIdToken();

            if (token == null)
                account = null;
            else
            {
                account = null;
                JWT jwt = new JWT(token);
                boolean isExpired = jwt.isExpired(10);

                if (isExpired)
                {
                    Log.d(GOOGLE_TAG, "Google silentSignIn result.");

                    try {
                        Task<GoogleSignInAccount> task = this.mGoogleSignInClient.silentSignIn();
                        account = task.getResult(ApiException.class);
                    } catch (ApiException exception) {
                    }
                }
            }
        }

BTW, I am using com.auth0.android.jwt.JWT (dependency is 'com.auth0.android:jwtdecode:1.3.0')

@baumblatt baumblatt added the enhancement New feature or request label Oct 16, 2019
@baumblatt
Copy link
Owner

Hi @yetanotherspinner ,

Great work, really thanks for sharing this.

Are you willing to fix it through a PR? If you prefer I can do it by my own.

If you like this plugin, please don't forget to star the project to help
others to find it.

Best regards,
Bernardo Baumblatt.

@yetanotherspinner
Copy link
Author

Hi Bernardo,

Sure, please fix it.

Thanks.

@baumblatt
Copy link
Owner

Hi @yetanotherspinner,

The version 0.2.4 is out there with your code, please let me know if everything ok and we can close this issue.

If you like this plugin, please don't forget to star the project to help
others to find it.

Best regards,
Bernardo Baumblatt

@yetanotherspinner
Copy link
Author

Works for me.

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

No branches or pull requests

2 participants