【问题标题】:Twitter OAuth throws 'Desktop applications only support the oauth_callback value oob' on iOS appTwitter OAuth 在 iOS 应用程序上抛出“桌面应用程序仅支持 oauth_callback 值 oob”
【发布时间】:2017-07-23 20:14:55
【问题描述】:

因此,我目前正在尝试通过使用OAuthSwift 插件来获得 twitter 工作的授权,我试图让它与 OAuth1 和 OAuth2 一起工作,但都失败了,并且出现了不同的错误/问题。

所以对于 OAuth2 我得到了这个响应

哇!
此页面没有请求令牌。这是我们要求使用您的 Twitter 帐户的应用程序所需的特殊密钥。请返回将您发送到此处的站点或应用程序,然后重试;这可能只是一个错误。

我正在为此使用以下代码

let oauthswift = OAuth2Swift(
            consumerKey: Twitter.consumerKey,
            consumerSecret: Twitter.consumerSecret,
            authorizeUrl: Twitter.authorizeURL,
            accessTokenUrl: Twitter.accessTokenURL,
            responseType: Twitter.responseType!)

let state = generateState(withLength: 20)

        oauthswift.authorize(
            withCallbackURL: "https://oauthswift.herokuapp.com/callback/twitter",
            scope: "",
            state: state,
            success: { credential, response, parameters in
                print("logged in with \(credential), with response \(response) and parameters \(parameters)")
            },
            failure: { error in
                print("error occured \(error.localizedDescription)")
            }
        )

然后我继续使用 OAuth1,这给了我错误 Desktop applications only support the auth_callback value 'oob' 虽然我显然是在尝试从 iOS 应用程序中执行此操作。

我这里使用的代码如下

let oauthTwitter = OAuth1Swift(
            consumerKey: "myKey",
            consumerSecret: "mySecret",
            requestTokenUrl: "https://api.twitter.com/oauth/request_token",
            authorizeUrl: "https://api.twitter.com/oauth/authorize",
            accessTokenUrl: "https://api.twitter.com/oauth/access_token")

oauthswift.authorize(
            withCallbackURL: "https://oauthswift.herokuapp.com/callback/twitter",
            scope: "",
            state: state,
            success: { credential, response, parameters in
                print("logged in with \(credential), with response \(response) and parameters \(parameters)")
            },
            failure: { error in
                print("error occured \(error.localizedDescription)")
            }
        )

我希望有人能够告诉我我在这里做错了什么,因为我似乎无法弄清楚。

【问题讨论】:

  • 对于 OAuth1 错误?你在 Twitter 控制台中正确设置了回调 url 吗?
  • 是的,问题最终导致我的 url 方案格式错误,其中包含 _,这是不允许的

标签: ios swift twitter oauth oauth-2.0


【解决方案1】:

问题最终是我设置了错误的 url 方案。它包含一个不允许的 _

【讨论】:

  • 嘿,NoSixties。我有同样的问题。我的方案没有下划线。您是否让它适用于 OAuth1 或 2?你有机会发布工作代码吗?您的 OAuth2 代码引用“Twitter”类型来获取字符串。我正在尝试使用 OAuth2。
【解决方案2】:

就我而言,我没有在 Twitter 开发网站上为应用设置回调 URL - https://developer.twitter.com/en/apps

【讨论】:

    猜你喜欢
    • 2014-02-05
    • 1970-01-01
    • 2011-02-13
    • 2011-04-14
    • 2016-01-27
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 2014-01-10
    相关资源
    最近更新 更多