Reputation: 305
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.
Upvotes: 1
Views: 1211
Reputation: 274
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
Upvotes: 1