How does one get the app access token for debug_token inspection on Facebook?

喜夏-厌秋 提交于 2019-12-11 03:45:59

问题


It is suggested that whether your app uses code or token as your response_type you should perform an automated check on the access_token to confirm that the token belongs to the person the app expects it to belong to and that it was your app that generated the token.

You are supposed to do this on

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

where app-token is app_id|app_secret and token-to-inspect is the user's access_token. Also, I think from reading the documentation you can retrieve an app-token by doing a client-credentials call with the app_id and app_secret.

This is fine with an authorization flow implemented server-side, but what if you're using the implicit method and chose response_type as token (and for whatever reason aren't using FB's javascript SDK)? How do you safely get that app-token without leaking your app_secret? How does FB's SDK do it?


回答1:


You can generate an app_token in your Facebook developer panel here and then simply save it into a config file server side. From the developer's page:

App tokens do not expire and should be kept secret as they are related to your app secret.

On my page, I use the following flow:

  1. The user authenticates with the Facebook JS SDK, and then sends his token + uid to the server.
  2. The server validates that the given token is related to the given person via a call to the "debug_token" method, that you spoke of.
  3. If the token + uid combination is valid, it authenticates the user server side.

I hope this helps.



来源:https://stackoverflow.com/questions/16641083/how-does-one-get-the-app-access-token-for-debug-token-inspection-on-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!