我正在开发一个项目,我正在实施OAuthSwift库,以连接到使用OAuth1和OAuth2的几个不同的社交网站.
我将应用程序设置为加载Web视图,将我带到我的社交网站,但我无法让应用程序重定向回来.我加载凭据后,它会要求我授予对应用程序进行授权的权限,但是一旦我这样做,就会加载我的社交网站主页.
我可以导航回应用程序,但它没有注册它已获得访问我的帐户的权限.
这是我第一次使用OAuth,发现回调网址令人困惑.
我将非常感谢帮助解释如何让Web视图重定向回我的应用程序以及如何设置应用程序的URL.
class ViewController:UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func postToTumblr(sender: AnyObject) {
let oauthSwift = OAuth1Swift(
consumerKey: "consumerKey",
consumerSecret: "secretKey",
requestTokenUrl: "https://www.tumblr.com/oauth/request_token",
authorizeUrl: "https://www.tumblr.com/oauth/authorize",
accessTokenUrl: "https://www.tumblr.com/oauth/access_token"
)
oauthSwift.authorizeWithCallbackURL(NSURL(string: "com.myCompany.sampleApp")!,
success: { credential, response in
// post to Tumblr
print("OAuth successfully authorized")
}, failure: {(error:NSError!) -> …Run Code Online (Sandbox Code Playgroud)