Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
860 views
in Technique[技术] by (71.8m points)

oauth 2.0 - Does my Google oAuth2 Token look right?

I am programming a web server to support oAuth2 for Google APIs and am following this documentation. Everything seems to be working fine up to the point where I try to make a Google API using the Access Token. Example call from the documentation:

https://www.googleapis.com/oauth2/v1/userinfo?access_token=1/fFBGRNJru1FQd44AzqT3Zg

When I try it with my access token I get 401 invalid token error.

Looking through the literature, all examples show the Access Token in format 1/fFBGR....... My Access Token is of form ya29.AHES67z....... and is much longer (see the snippet below containing response from google).

oauth2 request:{
"access_token" : "ya29.AHES67zeEn-RDg9CA5gGKMLKuG4uVB7W4O4WjNr-NBfY6Dtad4vbIZ",
"token_type" : "Bearer",
"expires_in" : 3600
}

So it appears my token is incorrect. Do I have to encode/decode it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've been recently playing around with OAuth2.0 from VBA.

Authorization Code Begins With: 4/Omoy    (30 Characters Long)  
Access_Token Begins With:       ya29.AHES (60 Characters Long)    
Refresh_Token Begins With:      1/Ry68    (45 Characters Long)  

I didn't have to do any decoding or encoding to use these values. These were working, functional values.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...