Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook redirect_uri set to ios URL Scheme

I'm starting to investigate how to work with Facebook programmatically.

I've set URL scheme in my app, so that I could open it from browser using "myappopenup://".

Then I created an app in Facebook. Copied an AppId and tried to make like this:

let url = NSURL(string: "https://www.facebook.com/dialog/oauth?client_id={MY_APP_ID_WAS_HERE}&redirect_uri=myappopenup://fbcallback")
UIApplication.sharedApplication().openURL(url!)

After running this code, simulator opened safari (I've tried with SFSafariViewController first). but everything I saw was:

enter image description here

So, I'd like to know: Is it possible to redirect from the Facebook oauth to my app?

like image 270
Nikolay Pryahin Avatar asked Jul 08 '16 07:07

Nikolay Pryahin


People also ask

How do I turn off use strict mode for redirect URIs on Facebook?

Due to the security changes made to Facebook, it's no longer possible to turn off this setting. If you are using HTTPS, you will need to enter the URI with the port number as well i.e. This last point is not related to the recent Facebook app changes. Save this answer.

How do I redirect a URL in Facebook developer?

In the App Dashboard, choose your app and scroll to Add a Product Click Set Up in the Facebook Login card. Select Settings in the left side navigation panel and under Client OAuth Settings, enter your redirect URL in the Valid OAuth Redirect URIs field for successful authorization.

How do I add this OAuth redirect URI to my Facebook app configuration?

Selecting the app, will take you to the settings for that app. In your app settings on https://developers.facebook.com/sa/apps/<my-app-id> , make sure that you add the Facebook Login product. Then under "Client OAuth Settings" enter the URL in the "Valid OAuth redirect URIs" box.


3 Answers

Yes it is possible. Here's the necessary redirect_uri:

  https://graph.facebook.com/oauth/authorize
  ?response_type=token
  &client_id='+'1247676148624015
  &redirect_uri=fb1247676148624015://authorize

Make sure your facebook app is set up:

Facebook App Setup

And make sure your custom URL scheme is set up:

enter image description here

Disappointing comment above -- likely misled many people. This stuff is not well-documented at all, though.

like image 100
Alex Paterson Avatar answered Sep 25 '22 05:09

Alex Paterson


I contacted Facebook support and they confirmed that it's not supported:

Thanks for getting in touch. We'll make the messaging more clear on this, but we do not support custom URI schemes as valid redirect URIs. To perform login in a native app without opening the browser, please use the official SDKs (is https://github.com/xamarin/FacebookComponents what you're looking for?).

They responded in less that 12 hours, which at least was impressive.

like image 20
Steve Hurcombe Avatar answered Sep 22 '22 05:09

Steve Hurcombe


I managed to make Alex Paterson solution work here. I had to add the redirect_uri URL on Facebook Login settings too. On section Valid OAuth redirect URIs I've added the callback URL like this:

https://graph.facebook.com/oauth/authorize?
response_type=token&
client_id=12345678910&
redirect_uri=fb12345678910://authorize
like image 31
alemorgado Avatar answered Sep 25 '22 05:09

alemorgado