如何验证 Facebook 访问令牌? [英] How to verify Facebook access token?

查看:35
本文介绍了如何验证 Facebook 访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务器只需要做一件事;只需检查任何访问令牌的有效性.

There's only thing that server has to do; just check any access token's validity.

客户端向服务器发送通过 FB.getLoginStatus 获得的用户 ID 和访问令牌.正如我所料,会有任何 URL 来检查访问令牌的有效性,例如 http://xxx.facebook.com/access_token?=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

Clients send to the server user id and access token obtained by FB.getLoginStatus. As I expected, there would be any URL that checks access token's validity, like http://xxx.facebook.com/access_token?=xxxxxxxxxxxxxxxxxxxxxxxxxxxx.

返回它是否可用,或者是否有任何 API(服务器端)?

That returns whether it's available one or not or is there any API (server side) for that?

推荐答案

官方支持的方法是:

GET graph.facebook.com/debug_token?
     input_token={token-to-inspect}
     &access_token={app-token-or-admin-token}

请参阅检查令牌文档 了解更多信息.

See the check token docs for more information.

一个示例响应是:

{
    "data": {
        "app_id": 138483919580948, 
        "application": "Social Cafe", 
        "expires_at": 1352419328, 
        "is_valid": true, 
        "issued_at": 1347235328, 
        "metadata": {
            "sso": "iphone-safari"
        }, 
        "scopes": [
            "email", 
            "publish_actions"
        ], 
        "user_id": 1207059
    }
}

这篇关于如何验证 Facebook 访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆