Google cloud print get access token
Asked Answered
C

2

8

I want to call /search method of Google cloud print from my webServer.

I am using OAuth web server guide obtaining a refresh_token/access_token to use with scopes:

https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile

Then I am calling search Api but I am obtaining a 403 forbidden.

    Request DefaultHttpRequest(chunked: false)
    POST /cloudprint/search HTTP/1.1
    Host: www.google.com
    Content-Type: text/plain; charset=utf-8
    Authorization: OAuth yb29.1.AADtN_U9PYyVhGpcS-8MpFhfGVbT4KsZKEoIX2HGePwoNXypjrSwVsS0pGzmaqhktfGBAQ
    Connection: keep-alive
    Accept: */*
    User-Agent: NING/1.0
    Content-Length: 0

    Response DefaultHttpResponse(chunked: true)
    HTTP/1.1 403 Forbidden
    Content-Type: text/html; charset=utf-8
    Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    Pragma: no-cache
    Expires: Fri, 01 Jan 1990 00:00:00 GMT
    Date: Tue, 03 Dec 2013 17:05:09 GMT
    Set-Cookie: NID=67=MQJFdl-YkMdz875n1J2yVNmeUeAvsjVtDGlNvGkNLZdNTHX3YbnStNx9Vg_MiRsmht6hj3XrwJcPJEQeFLlnYKqt2Of1xHJ5HDwNJgOB3svOdnN-JRFcPxYt4AU10eSM;Domain=.google.com;Path=/;Expires=Wed, 04-Jun-2014 17:05:09 GMT;HttpOnly
    P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-XSS-Protection: 1; mode=block
    Server: GSE
    Alternate-Protocol: 443:quic
    Transfer-Encoding: chunked

Is the scope correct? What am I doing wrong?

Crat answered 3/12, 2013 at 17:10 Comment(0)
C
5

Your scopes are wrong. The correct scope is https://www.googleapis.com/auth/cloudprint

Ciao answered 24/2, 2016 at 17:23 Comment(2)
thanks @EvanC, would you be able to link to the reference of where this is from? I have been unable to find this in google documentation.Cellulosic
@JoshMc developers.google.com/identity/protocols/…Ciao
L
0

I think this related to your HTTP Header 'Authorization'.

When playing at https://developers.google.com/oauthplayground/, I see the generated requests use 'Authorization: Bearer your-token', instead of 'Authorization: OAuth your-token'.

Luster answered 3/12, 2013 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.