Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass 'Authorization' header value in OAuth 2.0 with Google APIs

I am trying to access Google's APIs with OAuth 1.0 and 2.0 in both cases I need to fill Authorization field in the headers with value 'OAuth' followed by access token. I tried following method, but Google throws me an error saying there is problem in Authorization header values. I am using Python-Tornado

additional_headers = {
        "Authorization": "OAuth "+GoogleOAuth2Mixin.access_token,
        "Accept-Encoding": None
    }
    h = httputil.HTTPHeaders()
    h.parse_line("Authorization: OAuth "+GoogleOAuth2Mixin.access_token)
    request = httpclient.HTTPRequest(self._USER_INFO_URL+"?access_token="+GoogleOAuth2Mixin.access_token, method="GET", headers=h)
    self.httpclient_instance.fetch(
        request,
        self.async_callback(callback)
    )

I tried using both methods, by passing header 'h' and 'additional_headers', but it doesn't work. What is an accurate method?

like image 960
Kuldeep Kapade Avatar asked Oct 22 '25 06:10

Kuldeep Kapade


1 Answers

I had same problem. It works if 'Bearer ' is included as prefix.

Authorization: Bearer 0b79bab50daca910b000d4f1a2b675d604257e42
like image 150
user1297061 Avatar answered Oct 23 '25 20:10

user1297061



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!