Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:40:01+00:00 2026-06-11T21:40:01+00:00

I have implement function retrieve credentials from saved token in SharedPreferences . mCredential =

  • 0

I have implement function retrieve credentials from saved token in SharedPreferences.

mCredential = new GoogleCredential.Builder()
                   .setClientSecrets(CLIENT_ID, CLIENT_SECRET)
                   .setJsonFactory(mJsonFactory)
                   .setTransport(mHttpTransport).build();

mCredential.setRefreshToken(accessRefreshTokenSave);
mCredential.setAccessToken(accessTokenSave);

Long expires = mCredential.getExpiresInSeconds();
boolean result = mCredential.refreshToken();

When the token is expired. We should call mCredential.refreshToken() to refresh the token, is it right ?

When i call refreshToken i got exception.

com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
  "error" : "invalid_grant"
}

What should i need to do to refresh the token ? I found some document in Using OAuth 2.0 say about refresh token. But i don’t know how to implement it in Android code? Is there any sample code do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:40:02+00:00Added an answer on June 11, 2026 at 9:40 pm

    Generally (in my experience, since I haven’t found any documentation) ‘invalid grant’ means there is some problem with your stored refresh token. This includes (I think):-

    1. The user has revoked it
    2. Your testing has caused multiple refresh tokens to be generated. Only 25 may be extant
    3. The scopes associated with the stored token have changed

    To recover the situation, delete the stored refresh token and start the process again. The good news, is that apart from the user revocation scenario (1) this is a testing environment issue and doesn’t necessarily mean you have a bug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to implement a function to get headers only (without doing a GET
I have an abstract base class and want to implement a function in the
I have a Linked List and I want to implement a function: Random_Shuffle_List (struct
I have created a function to implement the regex.split in sql. Here's the code:
Hello guys, I have been trying to implement the DSUM function but failed to
I have a custom app which uses the crmservice.asmx to retrieve contacts from dynamics
So I have this function: (define (try try-block catch-block finally-block) ; Implements try/catch/finally like
MyActivity implements a CustomListener defined in MyClass.java. I have a function defined in MyClass
as the question states. I have implemented a function wherein it fetches multiple rows
I've got a simple C class I have implemented, using function pointers in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.