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

  • SEARCH
  • Home
  • 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 8596349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:39:19+00:00 2026-06-12T00:39:19+00:00

I have initialized the GoogleCredential variable from saved-access-token and saved-refresh-token. But i don’t know

  • 0

I have initialized the GoogleCredential variable from saved-access-token and saved-refresh-token. But i don’t know to check it expired or not ?

I know that GoogleCredential has a function getExpiresInSeconds. But if i initialize GoogleCredential from the saved-access-token and saved-refresh-token,the function getExpiresInSeconds will return null.

This case getExpiresInSeconds will not null

mResponse = mFlow.newTokenRequest(code).setRedirectUri(REDIRECT_URI).execute();
mCredential =  new GoogleCredential.Builder().setClientSecrets(CLIENT_ID, CLIENT_SECRET).setJsonFactory(mJsonFactory).setTransport(mHttpTransport).build();
mCredential.setFromTokenResponse(mResponse);
mCredential.getExpiresInSeconds() // will return expired value in second

but in this case

String accessTokenSave = mPrefs.getString(GOOGLE_DRIVE_TOKEN, "NO KEY");
String accessRefreshTokenSave = mPrefs.getString(GOOGLE_DRIVE_REFRESH_TOKEN, "NO KEY");

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

mCredential.setAccessToken(accessTokenSave);
mCredential.setRefreshToken(accessRefreshTokenSave);
mCredential.getExpiresInSeconds() // will return null value

So how can i check mCredential the case load it from accessTokenSave and accessRefreshTokenSave

  • 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-12T00:39:21+00:00Added an answer on June 12, 2026 at 12:39 am

    An access token expires in one hour while the refresh token will be valid until revoked by the user. However, you should never rely on these times and instead be prepared to catch an exception whenever credentials are no longer valid, and react accordingly.

    Check the documentation for the description on the complete flow, together with sample code implementing it: https://developers.google.com/drive/credentials

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

Sidebar

Related Questions

Error % javac StringTest.java StringTest.java:4: variable errorSoon might not have been initialized errorSoon[0] =
$ javac InitInt.java InitInt.java:7: variable right might not have been initialized InitInt(){} ^ 1
I have a class that needs to be initialized but it's namespaced like this:
I have a NSDate *date1 in class1 implementation file(I initialized it as Global variable).
I have initialized an delegate object in ViewDidLoad of my ViewController , but when
I have initialized a variable called lets say a = 0; when the user
I have correctly initialized YouTubeService. I can move/delete/rename playlist entries, but when I try
I get the error: TestCounter.java:115: variable counters might not have been initialized counters[i] =
I have vector< pair<int, int>> myVec (N); I want to have all pairs initialized
I have a Document object initialized in the init() method of the servlet and

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.