gpt4 book ai didi

iphone - 如何在 jQueryMobile 应用程序中使用 Foursquare OAuth2 进行身份验证(无用户代理流程)

转载 作者:行者123 更新时间:2023-12-03 20:08:45 24 4
gpt4 key购买 nike

我正在使用 jQueryMobile 构建一个移动应用程序,并且打算通过 PhoneGap 将其部署到 iPhone 上。

我的问题是:如何在 jQueryMobile 应用程序中使用 OAuth2 协议(protocol)通过 Foursquare 验证自己的身份?一种解决方案是使用 OAuth2 的用户代理流程,但这会迫使 iPhone 启动 Safari,从而不会停留在应用程序中。还有比这更好的解决方案吗?

最佳答案

对于基于 iPhone 或客户端应用程序(例如 PhoneGap 中的应用程序),Foursquare 推荐其中一种方法。

  • If you have no substantive server code, you can embed a web browser and use the token flow, redirecting the user to a dummy page on your domain. You can then grab the token off of the URL and close the browser. We have sample Android and iOS code for your reference.
  • If you have a server as part of your application, you can use the server flow above, possibly in an embedded browser. Similar to the Facebook API, you can add display=touch to your authorize or authenticate URLs to get a mobile optimized interface.
  • An alternative to the above is to use the server flow and an external browser, but redirect to a custom URI handler that brings the user back to our application. You can embed the secret in your application and exchange the provided code for an access token. PLEASE take steps to obfuscate your client secret if you include it in released code, and be prepared to rotate it if needed.

https://developer.foursquare.com/docs/oauth.html

这可能可以通过 PhoneGap 的 ClientBrowser 插件来处理,或者只需将他们提供的示例代码调整到 PhoneGap 插件中即可。

关于iphone - 如何在 jQueryMobile 应用程序中使用 Foursquare OAuth2 进行身份验证(无用户代理流程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6130207/

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