Facebook Graph API-授权类型? [英] Facebook Graph API - authorization types?
问题描述
我正在努力使用新的Facebook Graph API,也许这里有人可以提供帮助.
I'm struggling with the new Facebook Graph API, perhaps someone here can help.
这是我要执行的操作:提供一个使用FB登录"按钮,投递到/authorize,获取代码,投递到/access_token,获取access_token,并能够按
Here is what I want to do: provide a ‘login w/ FB’ button, throw to /authorize, get a code, throw to /access_token, get an access_token, and be able to hit https://graph.facebook.com/me for info about the user.
当我尝试在/authorize调用中使用type = client_cred时,我得到一个access_token,可以让我命中带有用户ID或名称的URL,但不能命中/me.我收到一条错误消息,指出我需要一个有效的令牌.
When I try to use type=client_cred in the /authorize call, I get an access_token that lets me hit URLs with userIDs or names, but not /me. I receive an error stating I need a valid token.
如果我无法打/me,如何确定当前用户是谁?
If I can't hit /me, how do I figure out who the current user is?
如果我想让网站访问用户数据,我应该在类型参数中使用什么?我看过带有type = web_server的帖子,等等,但是我似乎找不到确定的可行方法,我认为这很简单...
What exactly should I use in the type param if I want a website to access a users data? I've seen posts with type=web_server, etc, but I can't seem to find a sure fire way to do, what I think, is pretty simple...
提前感谢您提供的任何帮助...
Thanks ahead of time for any help thats provided...
推荐答案
当我尝试在/authorize调用中使用type = client_cred时,我得到一个access_token,可以让我命中带有用户ID或名称的URL,但不能命中/me.我收到一条错误消息,指出我需要一个有效的令牌.
When I try to use type=client_cred in the /authorize call, I get an access_token that lets me hit URLs with userIDs or names, but not /me. I receive an error stating I need a valid token.
client_cred
用于让您的应用验证其确实是该应用.它用于订阅Facebook的实时更新API之类的事情.它赋予否用户身份验证.
client_cred
is intended for your app to validate that it is, indeed, the app. It's used for things like subscribing to Facebook's real-time update API. It imparts no user authentication.
您需要遵循Facebook的 OAuth说明.它不以任何方式使用type
参数.您将是:
You need to follow Facebook's OAuth instructions. It does not use the type
parameter in any way. You'll be:
- 使用以下命令将用户发送到 https://graph.facebook.com/oauth/authorize 回调URL集.
- 如果用户说确定",他们将被重定向到您的回调URL,并以验证字符串作为URL参数.
- 您使用该验证字符串并从 https://graph.facebook.com/oauth请求访问令牌/access_token
- Sending the user to https://graph.facebook.com/oauth/authorize with a callback URL set.
- If the user says OK, they'll be redirected to your callback URL with a verification string as a URL parameter.
- You take that verification string and request an access token from https://graph.facebook.com/oauth/access_token
该访问令牌使您可以充当用户并访问me
URL.
That access token lets you function as the user and access the me
URLs.
这篇关于Facebook Graph API-授权类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!