gpt4 book ai didi

ios - Twitter OAuth 在 iOS 应用程序上抛出 'Desktop applications only support the oauth_callback value oob'

转载 作者:行者123 更新时间:2023-11-28 06:23:53 27 4
gpt4 key购买 nike

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

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

Whoa there!
There is no request token for this page. That's the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

我正在为此使用以下代码

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,这给了我错误桌面应用程序仅支持 auth_callback 值“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)")
}
)

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

最佳答案

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

关于ios - Twitter OAuth 在 iOS 应用程序上抛出 'Desktop applications only support the oauth_callback value oob',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42583625/

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