Facebook信使帐号链接,如何使用? [英] Facebook messenger account linking, how to use it?

查看:298
本文介绍了Facebook信使帐号链接,如何使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关帐户的文档中介绍了4个简单的步骤链接到信使平台:



  1. 使用登录按钮注册回调URL。 >


  2. Messenger Platform会在用户启动帐户关联流程时调用注册的URL。 redirect_uri和account_linking_token参数附加到您注册的回调。


  3. 链接完成后,将用户重定向到redirect_uri提供的位置,并附加一个authorization_code参数您可以使用帐户关联端点检索用户的页面范围ID(PSID)。





这个步骤只能在特殊情况下使用,当你需要用户的PSID作为链接过程的一部分。

这些步骤非常简单,除了没有任何帮助,无论如何实际链接帐户,我得到redirect_uri和account_linking_token作为参数在我的回调网站,我输入帐户登录和密码。



然后,我链接帐户?怎么样?



这个按钮有什么用?我知道这应该是连结帐户,但是我需要account_linking_token?我可以发送一个普通的web_url按钮用户psid,我可以很容易的发送它在我的登录按钮作为一个参数和链接帐户到这个psid如果凭据是正确的。



我坚信有一些我失踪的东西或者我不明白的东西,但是我不知道什么。我遵循这些步骤,称为端点链接以获取PSID,这是我已经拥有的,因为我是如何使用我的机器人发送消息的,但我并没有真正看到这个按钮。



那么,我失踪了什么?我是如此断裂。

解决方案

刚刚经历了一个类似的头部划痕,所以将解释我做了什么在我的头上新鲜



对于我的例子,我希望Facebook重定向到我的主登录页面,这是一个开放的id连接实现。客户登录到此,并从中获得一个id_token和access_token。在接收到access_token时,我从JWT中提取sub声明,这是我们数据库中唯一的客户标识符。



然后,我将重定向到在redirect_uri发送给我的值,附加authorization_code = {----sub-claim} p>

然后触发'帐户链接'webhook,这将发布到我的服务代码,其中包含Facebook用户的PSID和authorization_code,这是我在我的唯一客户ID业务数据库。



您现在拥有所需的2位信息,唯一的Facebook ID和您在Post消息中的唯一客户ID。此时您的业务代码可以将此信息存入某种存储空间。



在Bot端点的后续消息帖子中,您始终拥有发件人(PSID)在消息中。您的代码现在可以查找特定于您的业务的相应ID,并执行与该ID相关的操作。



链接发生在代码中,您需要从帐户链接webhook处理邮件,并存储数据以备将来使用。


There are 4 easy steps described in the documentation about account linking for the messenger platform:

  1. Register a callback URL using Log In Button.

  2. Messenger Platform invokes the registered URL when a user starts the account linking flow. The redirect_uri and account_linking_token parameters are appended to your registered callback.

  3. Once linking is complete, redirect users to the location provided by redirect_uri and append a authorization_code parameter (defined by you) to confirm linking.

  4. Optionally retrieve the user's page-scoped ID (PSID) using the account linking endpoint. This step should only be used in special cases when you need the user's PSID as part of the linking process.

These steps are very easy to follow, except there's no help whatsoever on how to actually link the account, I get the redirect_uri and the account_linking_token as parameters on my callback website where I enter the account login and password.

And then, I link the accounts...? How exactly?

What's the use on this button? I know it is supposed to link accounts, but what do I need the account_linking_token for? I can already send in a regular web_url button the user psid, I can easily send it on my login button as a parameter and link account to this psid if credentials are correct.

I strongly believe there's something I'm missing or something I'm not understanding, but I don't know what. I followed the steps, called the account linking endpoint to get the PSID, which I already had since it is how I send messages with my bot, but I don't really see the point on this button.

So, what am I missing? I'm so frustated.

解决方案

Just been through a similar bit of head scratching, so will explain what I've done while it's fresh in my head

For my example, I wanted Facebook to redirect out to my main login page, which is an open id connect implementation. The customer signs in to this, and I get an id_token and access_token back from that. Upon receiving the access_token, I'm extracting the 'sub' claim from the JWT, which is the unique customer identifier in our database.

I'm then redirecting back to the value that was sent to me in redirect_uri, appending authorization_code={the-value-of-the-sub-claim}

This then triggers the 'account link' webhook, which will Post to my service code, containing the PSID of the Facebook user and the authorization_code, which is my unique customer id in my business database.

You now have the 2 bits of information you need, the unique facebook id and your unique customer id in the Post message. It's up to your business code to persist this information to some sort of storage at this point

On subsequent message posts to the Bot endpoint, you always have the sender (PSID) in the message. Your code can now look up the corresponding id specific to your business and perform operations relevant for that id.

Where the linking takes place - that's in your code, you need to handle the message from the account link webhook and store the data for future use.

这篇关于Facebook信使帐号链接,如何使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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