gpt4 book ai didi

javascript - 如何使用来自 WebView 的 JS API 登录 facebook

转载 作者:行者123 更新时间:2023-11-30 06:53:44 24 4
gpt4 key购买 nike

我想从移动设备(WebView) 登录Facebook。我正在尝试使用本教程中的示例登录 https://developers.facebook.com/docs/facebook-login/login-flow-for-web

但是我收到以下错误

Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

根据这个manual ,我必须为 oauth 服务使用伪造的 redirect_uriWebView

登录

https://www.facebook.com/connect/login_success.html

现在,连接字符串看起来像这样

https://www.facebook.com/connect/ping?client_id=188978851312862&domain=&origin=1&redirect_uri=http://static.ak.facebook.com/connect/xd_arbiter.php?version=29#cb=fc2b211fc&domain=&origin=file%3A%2F%2F%2Ff3b6d7ef1c&relation=parent&response_type=token,signed_request,code&sdk=joey

如果你去这个链接,你会得到错误。但是,如果我将 redirect_uri 更改为此

https://www.facebook.com/connect/ping?client_id=188978851312862&domain=&origin=1&redirect_uri=https://www.facebook.com/connect/login_success.html&domain=&origin=file%3A%2F%2F%2Ff3b6d7ef1c&relation=parent&response_type=token,signed_request,code&sdk=joey

它会成功。

是否可以设置伪造的重定向 uri 并使用标准 JS API

UPD:实际上授权完全正确,但 API 的事件 (auth.authResponseChange) 没有触发。当我从移动设备的 WebView 登录时,redirect_uri 中的 origin 参数设置为 file:// 的问题。

最佳答案

据我所知,如果您在 WebView 中,“重定向到 https://www.facebook.com/connect/login_success.html”的建议是,它会重定向到那里,并使用一些身份验证 key “也在 url 中”,然后您可以解析它们并关闭您的 WebView,所以基本上是一次性标注,FWIW。我的另一个猜测是 origin 在那里,但实际上并没有被他们检查或使用 [?]

就“使用标准 JS API”而言,我认为你可以,但它是 non trivial see here .

关于javascript - 如何使用来自 WebView 的 JS API 登录 facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21553509/

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