Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
896 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...