gpt4 book ai didi

java - 用于 OAuth 身份验证的 Facebook 代码参数

转载 作者:行者123 更新时间:2023-12-04 06:04:38 25 4
gpt4 key购买 nike

我构建了一个 FB 应用程序,它执行以下操作:

1) 将初始请求重定向到 FB,以进行身份​​验证/登录,如下所示:

https://www.facebook.com/dialog/oauth?client_id=MYAPPID&redirect_uri=http://localhost:8080/FB/servlet&scope=read_stream&response_type=code

2)在servlet中,获取“code”参数(这是signed_request?):

 String signedReq = request.getParameter("code");

// the String retrieved from the code parameter is:
//3DaDJXq1Mlsq67GbeudlUxu7bY5Um4hSJlwzoPCHhp4.eyJpdiI6Ikc1ODNuRjZXbnhCb0hUV1FEMVNTQUEifQ._iXKxSGiNHfc-i5fRO35ny6hZ03DcLwu4bpAkslqoZk6OfxW5Uo36HwhUH2Gwm2byPh5rVp2kKCNS6EoPEZJzsqdhZ_MhuUD8WGky1dx5J-qNOUqQK9uNM4HG4ziSgFaAV8mzMGeUeRo8KSL0tcKuq

//This parameter contains '#_= _' at the end in the actual "code" but i am not able to get it through the request.getParameter("code");This is a java web app.

最佳答案

复制自 Facebook API's OAuth Page
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).
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE
If your app is successfully authenticated and the authorization code from the user is valid, the authorization server will return the access token.
所以是的,这是 OAuth 的标准。获取一个成功代码,将它输入到上面的 url(使用适当的 client_id、client_secret 和一个 redirect_uri),你应该是现金。你会得到一个访问 token ,然后是聚会时间。

阅读那篇 Facebook API 文章。这是非常有用的。如果您对此有任何疑问,我很乐意为您提供帮助。

祝你好运 :)

关于java - 用于 OAuth 身份验证的 Facebook 代码参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8510213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com