我正在尝试使用快速框架OAuthSwift通过Twitter OAuth 1.0为我的应用程序授权用户。虽然一切看起来都很好(safari打开了twitter页面,应用程序获得授权,然后重定向到我的应用程序)我不会得到我的oauth_token和oauth_token_secret。相反,我得到一个错误:"操作无法完成。 Oauth问题。"
let twitterConsumerKey = "********"
let twitterConsumerSecret = "***********************"
let twitterRequestTokenURL = "https://api.twitter.com/oauth/request_token"
let twitterAuthorizeURL = "https://api.twitter.com/oauth/authorize"
let twitterAccessTokenURL = "https://api.twitter.com/oauth/access_token"
let twitterAuth = OAuth1Swift(consumerKey: twitterConsumerKey,
consumerSecret: twitterConsumerSecret,
requestTokenUrl: twitterRequestTokenURL,
authorizeUrl: twitterAuthorizeURL,
accessTokenUrl: twitterAccessTokenURL)
twitterAuth.authorizeWithCallbackURL(NSURL(string: "oauth-swift://oauth-callback/twitter")!, success: {
credential, response in
println("///////////////////")
println("OK")
println(response)
println(credential.oauth_token)
println(credential.oauth_token_secret)
println("///////////////////")
}, failure: {(error:NSError!) -> Void in // <--this method runs
println("///////////////////")
println("FAIL")
println(error.localizedDescription) // <-- "The operation couldn’t be completed. Oauth problem."
println("///////////////////")
})