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

Unified Diff: chrome/common/net/gaia/oauth2_api_call_flow.cc

Issue 10080016: Set the authorization header when calling an API. Otherwise, no API call will succeed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
Index: chrome/common/net/gaia/oauth2_api_call_flow.cc
===================================================================
--- chrome/common/net/gaia/oauth2_api_call_flow.cc (revision 132216)
+++ chrome/common/net/gaia/oauth2_api_call_flow.cc (working copy)
@@ -8,6 +8,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/stringprintf.h"
#include "chrome/common/net/gaia/gaia_urls.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
@@ -21,6 +22,15 @@
using net::URLRequestContextGetter;
using net::URLRequestStatus;
+namespace {
+static const char kAuthorizationHeaderFormat[] =
+ "Authorization: Bearer %s";
+
+static std::string MakeAuthorizationHeader(const std::string& auth_token) {
+ return StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str());
+}
+} // namespace
+
OAuth2ApiCallFlow::OAuth2ApiCallFlow(
net::URLRequestContextGetter* context,
const std::string& refresh_token,
@@ -146,6 +156,7 @@
result->SetRequestContext(context_);
result->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES);
+ result->AddExtraRequestHeader(MakeAuthorizationHeader(access_token_));
if (!empty_body)
result->SetUploadData("application/x-www-form-urlencoded", body);
« no previous file with comments | « chrome/common/net/gaia/oauth2_api_call_flow.h ('k') | chrome/common/net/gaia/oauth2_api_call_flow_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698