简体   繁体   中英

Facebook OAuthSwift redirect_uri not supported iOS

I am trying to use OAuthSwift to get the user's access token in my app. I already did this with Twitter and Instagram , but Facebook is not helping me.

The code I am using is the following:

    func doOAuthFacebook () {
    let oauthswift = OAuth2Swift(
        consumerKey:    "@@@@",
        consumerSecret: "####",
        authorizeUrl:   "https://www.facebook.com/dialog/oauth",
        responseType:   "token"
    )
    oauthswift.authorizeWithCallbackURL(NSURL(string: "myApp://myApp/facebook")!, scope: "publish_stream,email", state: "FACEBOOK", success: { (credential, response, parameters) -> Void in

        self.showAlertView("Facebook", message: "oauth_token:\(credential.oauth_token)")

        }) { (error) -> Void in

            print (error.localizedDescription)
    }
}

The callbackURL that I am using works for the other two social networks. From Facebook I am receiving this message when Safari tries to open the page:

The redirect_uri URL is not supported

I don't know if I have to do something to my app in Facebook Developers page, or it is something else.

This case is documented in project wiki page https://github.com/OAuthSwift/OAuthSwift/wiki/API-with-only-HTTP-scheme-into-callback-URL

two way:

  • have an http server and redirect to your application scheme

  • use a delegate into a webview to handle fake http url and redirect to your application scheme or call directly OAuthSwift.handleOpenURL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM