Index: google_apis/gaia/gaia_auth_fetcher.cc |
=================================================================== |
--- google_apis/gaia/gaia_auth_fetcher.cc (revision 177312) |
+++ google_apis/gaia/gaia_auth_fetcher.cc (working copy) |
@@ -21,6 +21,7 @@ |
#include "google_apis/gaia/google_service_auth_error.h" |
#include "net/base/escape.h" |
#include "net/base/load_flags.h" |
+#include "net/http/http_response_headers.h" |
#include "net/http/http_status_code.h" |
#include "net/url_request/url_fetcher.h" |
#include "net/url_request/url_request_context_getter.h" |
@@ -156,6 +157,9 @@ |
// static |
const char GaiaAuthFetcher::kOAuthHeaderFormat[] = "Authorization: OAuth %s"; |
// static |
+const char GaiaAuthFetcher::kOAuth2BearerHeaderFormat[] = |
+ "Authorization: Bearer %s"; |
+// static |
const char GaiaAuthFetcher::kClientLoginToOAuth2CookiePartSecure[] = "Secure"; |
// static |
const char GaiaAuthFetcher::kClientLoginToOAuth2CookiePartHttpOnly[] = |
@@ -354,7 +358,9 @@ |
using std::vector; |
using std::pair; |
using std::string; |
- |
+ sid->clear(); |
+ lsid->clear(); |
+ token->clear(); |
vector<pair<string, string> > tokens; |
base::SplitStringIntoKeyValuePairs(data, '=', '\n', &tokens); |
for (vector<pair<string, string> >::iterator i = tokens.begin(); |
@@ -367,6 +373,10 @@ |
token->assign(i->second); |
} |
} |
+ // If this was a request for uberauth token, then that's all we've got in |
+ // data. |
+ if (sid->empty() && lsid->empty() && token->empty()) |
+ token->assign(data); |
} |
// static |
@@ -434,7 +444,8 @@ |
const std::string& source) { |
std::string encoded_service = net::EscapeUrlEncodedData(service, true); |
std::string encoded_source = net::EscapeUrlEncodedData(source, true); |
- return StringPrintf(kOAuthLoginFormat, encoded_service.c_str(), |
+ return StringPrintf(kOAuthLoginFormat, |
+ encoded_service.c_str(), |
encoded_source.c_str()); |
} |
@@ -770,7 +781,7 @@ |
request_body_ = MakeOAuthLoginBody(service, source_); |
std::string authentication_header = |
- base::StringPrintf("Authorization: Bearer %s", access_token.c_str()); |
+ base::StringPrintf(kOAuth2BearerHeaderFormat, access_token.c_str()); |
fetcher_.reset(CreateGaiaFetcher(getter_, |
request_body_, |
authentication_header, |
@@ -1072,8 +1083,16 @@ |
int response_code = source->GetResponseCode(); |
std::string data; |
source->GetResponseAsString(&data); |
- DVLOG(2) << "Gaia fetcher response code: " << response_code; |
- DVLOG(2) << "Gaia fetcher response data: " << data; |
+#ifndef NDEBUG |
+ std::string headers; |
+ if (source->GetResponseHeaders()) |
+ source->GetResponseHeaders()->GetNormalizedHeaders(&headers); |
+ DVLOG(2) << "Response " << url.spec() << ", code = " << response_code << "\n" |
+ << headers << "\n"; |
+ DVLOG(2) << "data: " << data << "\n"; |
+#endif |
+ // Retrieve the response headers from the request. Must only be called after |
+ // the OnURLFetchComplete callback has run. |
if (url == client_login_gurl_) { |
OnClientLoginFetched(data, status, response_code); |
} else if (url == issue_auth_token_gurl_) { |