Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from sungjungk/fixed-exp-handling
Browse files Browse the repository at this point in the history
Fixed 'exp' handling in ID token
  • Loading branch information
SurferJeffAtGoogle committed Apr 10, 2019
2 parents 546eef6 + c62e7bc commit 3eeb584
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/googleapis/client/auth/oauth2_authorization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,18 @@ util::Status OAuth2Credential::UpdateFromString(const string& json) {
access_token_.set(str_value);
VLOG(1) << "Updating access token";
}
if (data.GetString("expires_at", &str_value)
|| data.GetString("exp", &str_value)) {
if (data.GetString("expires_at", &str_value)) {
int64 timestamp;
if (!safe_strto64(str_value.c_str(), &timestamp)) {
LOG(ERROR) << "Invalid timestamp=[" << str_value << "]";
} else {
expiration_timestamp_secs_.set(timestamp);
VLOG(1) << "Updating access token expiration";
}
} else if (data.GetScalar("exp", &int_value)) {
int64 timestamp = int_value;
expiration_timestamp_secs_.set(timestamp);
VLOG(1) << "Updating access token expiration";
} else if (data.GetScalar("expires_in", &int_value)) {
int64 now = DateTime().ToEpochTime();
int64 expiration = now + int_value;
Expand Down

0 comments on commit 3eeb584

Please sign in to comment.