Google cloud print get access token

十年热恋 提交于 2019-12-05 21:35:33

问题


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?


回答1:


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




回答2:


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'.



来源:https://stackoverflow.com/questions/20357413/google-cloud-print-get-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!