Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1201)

Unified Diff: google_apis/gaia/oauth2_mint_token_flow.cc

Issue 14329014: Identity API: Add token cache and identity.invalidateAuthToken. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rounding third rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gaia/oauth2_mint_token_flow.h ('k') | google_apis/gaia/oauth2_mint_token_flow_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/oauth2_mint_token_flow.cc
diff --git a/google_apis/gaia/oauth2_mint_token_flow.cc b/google_apis/gaia/oauth2_mint_token_flow.cc
index 169d1871f9a1d70f13cffc1c5da8bd0b7f4a1976..9c5d9437dd3fe052bc95781864994a5fd547d8d6 100644
--- a/google_apis/gaia/oauth2_mint_token_flow.cc
+++ b/google_apis/gaia/oauth2_mint_token_flow.cc
@@ -14,6 +14,7 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "google_apis/gaia/gaia_urls.h"
@@ -45,6 +46,7 @@ static const char kIssueAdviceValueAuto[] = "auto";
static const char kIssueAdviceValueConsent[] = "consent";
static const char kAccessTokenKey[] = "token";
static const char kConsentKey[] = "consent";
+static const char kExpiresInKey[] = "expiresIn";
static const char kScopesKey[] = "scopes";
static const char kDescriptionKey[] = "description";
static const char kDetailKey[] = "detail";
@@ -102,9 +104,10 @@ OAuth2MintTokenFlow::OAuth2MintTokenFlow(URLRequestContextGetter* context,
OAuth2MintTokenFlow::~OAuth2MintTokenFlow() { }
-void OAuth2MintTokenFlow::ReportSuccess(const std::string& access_token) {
+void OAuth2MintTokenFlow::ReportSuccess(const std::string& access_token,
+ int time_to_live) {
if (delegate_)
- delegate_->OnMintTokenSuccess(access_token);
+ delegate_->OnMintTokenSuccess(access_token, time_to_live);
// |this| may already be deleted.
}
@@ -174,8 +177,9 @@ void OAuth2MintTokenFlow::ProcessApiCallSuccess(
ReportFailure(GoogleServiceAuthError::FromConnectionError(101));
} else {
std::string access_token;
- if (ParseMintTokenResponse(dict, &access_token))
- ReportSuccess(access_token);
+ int time_to_live;
+ if (ParseMintTokenResponse(dict, &access_token, &time_to_live))
+ ReportSuccess(access_token, time_to_live);
else
ReportFailure(GoogleServiceAuthError::FromConnectionError(101));
}
@@ -200,10 +204,15 @@ void OAuth2MintTokenFlow::ProcessMintAccessTokenFailure(
// static
bool OAuth2MintTokenFlow::ParseMintTokenResponse(
- const base::DictionaryValue* dict, std::string* access_token) {
+ const base::DictionaryValue* dict, std::string* access_token,
+ int* time_to_live) {
CHECK(dict);
CHECK(access_token);
- return dict->GetString(kAccessTokenKey, access_token);
+ CHECK(time_to_live);
+ std::string ttl_string;
+ return dict->GetString(kExpiresInKey, &ttl_string) &&
+ base::StringToInt(ttl_string, time_to_live) &&
+ dict->GetString(kAccessTokenKey, access_token);
}
// static
« no previous file with comments | « google_apis/gaia/oauth2_mint_token_flow.h ('k') | google_apis/gaia/oauth2_mint_token_flow_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698