获取facebook api的访问令牌
要获取访问令牌,
GET: https://graph.facebook.com/oauth/access_token? client_id=YOUR_APP_ID &client_secret=YOUR_APP_SECRET &redirect_uri=uri
我尝试使用Graph API Explorer中的以下GET方法
/oauth/access_token?client_id=XXXXX&client_secret=XXXXXXXXXXXXX&redirect_uri=http://XYZ.com/
但在这里我收到错误:
{ "error": { "message": "Missing authorization code", "type": "OAuthException", "code": 1 } }
能否请您建议, 代码参数应该传递什么。
/oauth/access_token?client_id=XXXXXX&client_secret=XXXXXXXXXXXXXXX&redirect_uri=http://XYZ.com/&code=??
您的GET参数不正确。 而是使用这个:
https://graph.facebook.com/oauth/access_token?client_id=XXXXX&client_secret=XXXX&grant_type=client_credentials
你错过了
grant_type = client_credentials
参数/值组合,这是接收访问令牌所必需的。
这将返回一个应用程序级别的oauth令牌,但您尚未引入授权权限列表的“ scope ”参数:
https://graph.facebook.com/oauth/access_token?client_id=&client_secret=&redirect_uri=http://example.com/&scope=&grant_type=client_credentials
有关可用权限的列表,您可以从应用程序的Facebook Explorer仪表板中选择“获取访问令牌”时找到它们 –
https://developers.facebook.com/tools/explorer//