2014-09-04 138 views

回答

5

使用谷歌OAuth园地:

https://developers.google.com/oauthplayground/

请求:

POST /oauth2/v3/token HTTP/1.1 
Host: www.googleapis.com 
Content-Type: application/x-www-form-urlencoded 

code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7& 
client_id=8819981768.apps.googleusercontent.com& 
client_secret={client_secret}& 
redirect_uri=https://oauth2-login-demo.appspot.com/code& 
grant_type=authorization_code 

(成功)响应:

{ 
    "access_token":"1/fFAGRNJru1FTz70BzhT3Zg", 
    "expires_in":3920, 
    "token_type":"Bearer" 
} 

我也强烈建议你阅读的谷歌OAuth 2.0文档 https://developers.google.com/accounts/docs/OAuth2WebServer

+21

这没有帮助IMO,你只是有同样的问题,因为你不能以编程方式生成一个代码。现在问题变成“如何获得虚拟的Google授权代码..​​....”。 Facebook提供了创建测试用户的能力,并通过使用您的https://graph.facebook.com/v2.4/{app-id}/accounts/test-users来即时获取该用户的访问令牌应用令牌。 – joelittlejohn 2015-08-04 16:32:39