【问题标题】:Twitter API: How Do I Create a Protocol Only Callback URL?Twitter API:如何创建仅协议回调 URL?
【发布时间】:2020-09-29 02:10:53
【问题描述】:

在 Twitter 的 Developer Documentation 中,我们可以阅读以下内容:

Mobile apps with app-specific protocols must use just the protocol
Example:
    You want to use example://authorize as your callback URL
    Add this to both your Twitter app dashboard and your call to oauth/request_token: example://

但是;在Developer's Dashboard 中,我无法输入仅协议 URL,或以 http 或 https 以外的任何 URL 开头。

我想要一个仅协议 URL 的原因是我可以在使用 OAuthSwift 访问 Web API 的 iOS 应用中使用。

有什么想法吗?

【问题讨论】:

    标签: twitter oauth ios13


    【解决方案1】:

    我还没有找到原始问题的答案,但我确实有一个很好的解决方法。所以,对于其他可能登陆这里的人:

    https://oauthswift.herokuapp.com/callback 的网络应用程序 将执行重定向。如果您使用 url https://oauthswift.herokuapp.com/callback/target 访问该网站,那么它将重定向到 oauth-swift://oauth-callback/target。

    所以:

    1. 在 Twitter 仪表板中输入 https://oauthswift.herokuapp.com/callback/SomeName 作为应用的回调 URL
    2. 在您的 iOS 应用的 URL 类型中将 oauth-swift 注册为 URL 方案
    3. 在您的 iOS 应用中,使用 https://oauthswift.herokuapp.com/callback/SomeName 作为 OAuth 授权请求的回调 URL。

    瞧。 Twitter 将重定向到 https://oauthswift.herokuapp.com/callback/SomeName,而https://oauthswift.herokuapp.com/callback/SomeName 又将重定向到 oauth-swift://oauth-callback/SomeName,从而让您的 iOS 应用重新获得对流程的控制。

    如果您发现其中任何一个令人困惑,那么这可能会有所帮助:http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-02
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 2014-02-04
      • 2015-07-30
      • 2017-08-31
      • 1970-01-01
      相关资源
      最近更新 更多