【发布时间】:2018-08-28 14:52:22
【问题描述】:
我想登录 Facebook 并重定向到我的应用,但我遇到了问题。有我的代码:
let oauthswift = OAuth2Swift(
consumerKey: "4242424242",
consumerSecret: "",
authorizeUrl: "https://www.facebook.com/dialog/oauth",
accessTokenUrl: "https://graph.facebook.com/oauth/access_token",
responseType: "code"
)
oauthswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthswift)
let state = generateState(withLength: 20)
guard let rwURL = URL(string:"https://myapp.test/callback/facebook") else { return }
let _ = oauthswift.authorize( withCallbackURL:rwURL, scope: "public_profile", state: state,
success: { credential, response, parameters in
..........}
Bundle is ID is myapp.test
Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp.test</string>
</array>
</dict>
</array>
当我尝试重定向到我的应用程序时“Safari 无法打开页面,因为找不到服务器”
在“有效 OAuth 重定向 URI”部分的 developers.facebook.com 页面中,我有相同的 url“https://myapp.test/callback/facebook”。我做错了什么? 谢谢。
【问题讨论】:
标签: ios swift facebook oauth-2.0 facebook-oauth