【发布时间】:2015-04-22 07:35:57
【问题描述】:
我不确定是否可以在 stackoverflow 中询问与 github 相关的源代码的问题,但我一直在试图理解代码库。
来源:https://github.com/gabriel-jones/OAuthSwift
我正在尝试将 OAuth2.0 集成到我的项目中以进行各种身份验证。 在 read.md 上,它说
let oauthswift = OAuth2Swift(
consumerKey: "********",
consumerSecret: "********",
authorizeUrl: "https://api.instagram.com/oauth/authorize",
responseType: "token"
)
oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth- swift://oauth-callback/instagram"), scope: "likes+comments", state:"INSTAGRAM", success: {credential, response in
println(credential.oauth_token) }, failure: failureHandler)
我不明白如何将成功作为参数发送?
我试过类似的东西:
var credential = OAuthSwiftCredential(consumer_key: "****", consumer_secret: "****")
var response : NSHTTPURLResponse? = nil
oauthswift.authorizeWithCallbackURL(callbackURL: NSURL(string: "oauth-swift://oauth-callback/"), scope: "***", state: "****", params: emptyDictionary, success: {
credential, response
}, failure: failureHandler())
我查看了实现类,但似乎没有掌握如何调用 authorizeWithCallbackURL() 方法。请告诉我。谢谢
【问题讨论】:
标签: ios swift github ios8 oauth-2.0