Facebook 解码的signed_request 包含文档中未提及的额外数据

发布于 2024-12-09 20:48:23 字数 752 浏览 2 评论 0原文

我有一个 Facebook signed_request,通过订阅 auth.login 事件以及用户使用 facebook 登录按钮

在解码 signed_request 后,其中包含以下信息:

{'issued_at': 1318492701, 
'code': 'AQCXI5aiyYtYLFNtkYhtKwDhO02lP[truncated]', 
'user_id': '100000xxxxxxxxx', 
'algorithm': 'HMAC-SHA256'}

我无法在<一href="http://developers.facebook.com/docs/authentication/signed_request/" rel="noreferrer">signed_request 文档。这个代码是什么以及它的用途是什么?

我认为它可能用于获取授权代码,如此线程 但除了 signed_request 之外,我还在登录事件的响应中收到了用户的访问令牌。

I have a Facebook signed_request which is received by subscribing to the auth.login event and after the user logs in using the facebook login button

After I decode the signed_request I have the following information in it:

{'issued_at': 1318492701, 
'code': 'AQCXI5aiyYtYLFNtkYhtKwDhO02lP[truncated]', 
'user_id': '100000xxxxxxxxx', 
'algorithm': 'HMAC-SHA256'}

I cannot find in the signed_request documentation. What is this code and what's its use?

I thought it might be used to obtain an authorization code as stated in this thread but along with the signed_request I also receive an access token for the user in the response from the login event.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏末的微笑 2024-12-16 20:48:23

我不知道为什么他们没有提到使用文档页面上的代码来签名请求。该代码可以交换为访问令牌,这是发出任何后续 Facebook API 请求的关键。

相关文档位于:https://developers.facebook.com/docs/authentication/

有了此代码,您就可以继续下一步,即应用程序身份验证,以获取进行 API 调用所需的访问令牌。

为了验证您的应用程序,您必须将授权代码和您的应用程序密钥传递到 Graph API 令牌端点 - 以及上面使用的完全相同的redirect_uri - 位于https://graph.facebook.com/oauth/access_token。应用程序密钥可从开发者应用程序获取,不应与任何人共享或嵌入到您将分发的任何代码中(对于这些场景,您应该使用客户端流程)。

I don't know why they don't mention use of the code on the documentation page for signed requests. The code can be exchanged for an access token that is the key to making any subsequent Facebook API requests.

Relevant documentation is here: https://developers.facebook.com/docs/authentication/

With this code in hand, you can proceed to the next step, app authentication, to gain the access token you need to make API calls.

In order to authenticate your app, you must pass the authorization code and your app secret to the Graph API token endpoint - along with the exact same redirect_uri used above - at https://graph.facebook.com/oauth/access_token. The app secret is available from the Developer App and should not be shared with anyone or embedded in any code that you will distribute (you should use the client-side flow for these scenarios).

殊姿 2024-12-16 20:48:23

这是来自 JavaScript SDK 的signed_request,对吧?该代码由 SDK 使用,但不用于服务器端身份验证。实际上,我们将更新文档以反映signed_request 行为。

This is the signed_request from the JavaScript SDK, right? The code is used by the SDK but isn't for the Server-side Authentication. Actually, we will update the documentation to reflect the signed_request behaviors.

小梨窩很甜 2024-12-16 20:48:23

该代码对于获取有关安装您的应用程序的用户的信息很有用

,但无论如何请告诉我您需要哪些信息,然后我可以


很好地为您提供示例代码,如果您再次检查您发布的代码,您会看到您有用户 ID
因此您不需要为此使用访问令牌,

但无论如何都可以获取基本信息和信息任何其他信息或发布&删除有两种方法:

第一种:直接删除(不需要sdk,但是更难)
第二:通过sdk(很简单)
我推荐你使用 sdk &如果您的服务器端编程语言是 PHP,您可以执行此操作来获取

    <?php
    include_once ('src/facebook.php');/// include sdk
    ////// config The sdk
        @ $facebook = new Facebook(array(
        'appId'  => '*************',
        'secret' => '*****************',
         )); 
$user=$facebook->api('me','GET');
echo '<pre>';
print_r($user);
echo '</pre>';
?>

下载的 基本信息
下载 php sdk

https://developers.facebook.com/docs/reference/php/

that code is useful to get information about users who installed your app

but anyway tell me which information is needed for you then i can give you sample code


well, if you check your posted code again you see you have user id
so you do not need to use access token for this

but anyway for getting basic information & any other information or posting & deleting you have two ways :

first:do it directly (no need to sdk,but harder)
second: via sdk (its easy)
i recommend to you to use sdk & if your server side programming language is PHP you can do this for getting basic information

    <?php
    include_once ('src/facebook.php');/// include sdk
    ////// config The sdk
        @ $facebook = new Facebook(array(
        'appId'  => '*************',
        'secret' => '*****************',
         )); 
$user=$facebook->api('me','GET');
echo '<pre>';
print_r($user);
echo '</pre>';
?>

for downloading
download php sdk

https://developers.facebook.com/docs/reference/php/

司马昭之心 2024-12-16 20:48:23

您必须访问此 Facebook 官方文档 并阅读“signed_request 参数”及其下面的文本解码signed_request后得到的代码

You have to visit this facebook offical doc and read "signed_request Parameter" and its below text for the code which you get after decoding signed_request

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文