【发布时间】:2020-09-22 10:03:08
【问题描述】:
我正在使用 OAuthSwift 和 Alamofire 发出 OAuth2 请求,一切正常,但我想让用户体验更好一点:当用户点击 OAuthSwift 中的日志时,会跳转到 Safari 收集凭据并验证用户身份,然后跳回应用程序。我想在应用程序中显示该屏幕,就像登录屏幕上的弹出视图控制器一样。
let oauthswift = OAuth2Swift(consumerKey: Credentials.client_id,
consumerSecret: Credentials.client_secret,
authorizeUrl: ZohoURL.authTokenUrl,
responseType: "code")
let _ = oauthswift.authorize(withCallbackURL: ZohoURL.redirect_uri, scope: "", state: "") { (result) in
switch result {
case .success(_):
print("success")
case .failure(_):
print("error")
}
}
}
代码用于身份验证(不包括处理响应,与此问题无关)
我为oauthswift 阅读了一些关于authorizeURLHandler 的内容,但我不明白如何使用它。
如果可以的话,我愿意接受另一个实现或可可豆荚。
【问题讨论】: