c# - Why is this access token invalid instantly? -
scenario:
created google+ sign-on button user log in. works.
saved access token , printed out on index/home page make sure access token exists. works.
attempt use same token authorize user account (mine in case) make authorized calls google apis. keeps responding "invalid_token".
so, why token invalid request made after save , print out access token page? calling wrong uri or providing wrong parameters? access token created response below see, includes status code, reasonphrase, requestmessage, headers, , content:
google response: unauthorized - unauthorized - method: get, requesturi: 'https://www.googleapis.com/consumersurveys/v2/surveys?key={my_api_key}', version: 1.1, content: , headers: { accept: application/json authorization: bearer abcdefghijklmnopqrstuvqxyz123456789 } - vary: x-origin, origin, accept-encoding x-content-type-options: nosniff x-frame-options: sameorigin x-xss-protection: 1; mode=block alternate-protocol: 443:quic alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30,29,28,27,26,25" transfer-encoding: chunked accept-ranges: none cache-control: max-age=0, private date: fri, 15 jul 2016 18:10:37 gmt server: gse www-authenticate: bearer realm="https://accounts.google.com/", error=invalid_token - system.net.http.streamcontent
google access token printed on page: abcdefghijklmnopqrstuvqxyz123456789
all trying make authorized calls google apis , in order have make request , specify api key, , provide access token (which matches printed token) when says invalid_token , unauthorized. why keep saying this?
this question extension of other question: get call google api responds "unauthorized"
i believe issue access token (which verified through postman) required more scopes authenticate me fully, makes sense since api contains surveys trying access, linked google account.
more info on adding scopes c# code can found here: http://www.oauthforaspnet.com/providers/google/
this answered here: why oauth 2.0 playground access tokens work google api?
Comments
Post a Comment