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

Add OAuth2Credentials#refreshIfExpired() #163

Merged
merged 3 commits into from Jun 26, 2018
Merged

Add OAuth2Credentials#refreshIfExpired() #163

merged 3 commits into from Jun 26, 2018

Conversation

chingor13
Copy link
Contributor

Adds instance method to explicitly refresh OAuth2Credentials if they need fetching or refreshing.

#143
#147

@chingor13 chingor13 merged commit 64b48cb into googleapis:master Jun 26, 2018
@chingor13 chingor13 deleted the refresh-if-expired branch June 26, 2018 22:15
@chingor13 chingor13 mentioned this pull request Jul 12, 2018
davidxia added a commit to spotify/helios that referenced this pull request Aug 17, 2018
We were mistakenly calling `GoogleCredentials.refreshAccessToken()`
which always makes a call to retrieve a new access token regardless of expiration.
In addition, this method returns an `AccessToken` which we accidentally
ignored. But this method but never sets the `AccessToken`
for the `getAccessToken()` method which we subsequently called.

Instead, we should use `GoogleCredentials.refreshIfExpired()`
which refreshes the token if only if it's close to expiring and returns
void. Our next call to `getAccessToken()` will actually return the refreshed
token in this case.

See googleapis/google-auth-library-java#163
davidxia added a commit to spotify/helios that referenced this pull request Aug 17, 2018
We were mistakenly calling `GoogleCredentials.refreshAccessToken()`
which always makes a call to retrieve a new access token regardless of expiration.
In addition, this method returns an `AccessToken` which we accidentally
ignored. But this method but never sets the `AccessToken`
for the `getAccessToken()` method which we subsequently called.

Instead, we should use `GoogleCredentials.refreshIfExpired()`
which refreshes the token if only if it's close to expiring and returns
void. Our next call to `getAccessToken()` will actually return the refreshed
token in this case.

See googleapis/google-auth-library-java#163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants