简体   繁体   中英

I got the error “The redirect_uri URL must be absolute” with Facebook SDK on iOS

I use this code on my app to start facebook login :

    [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES
                              completionHandler:^(FBSession *session,
                                                  FBSessionState status,
                                                  NSError *error) {
                                  NSLog(@"#####################");
                                  // session might now be open.
                                  [self sessionStateChanged:session state:status error:error];
                              }];

Safari start, but i got : 在此处输入图片说明

I read that this error is related to the URL key in the plist file, everything looks OK

在此处输入图片说明

Here are some settings of the facebook app :

在此处输入图片说明

在此处输入图片说明

This is very strange. Of course, i double check the fb ID and bundle identifier ...

Any idea ?

Thanks

UPDATE

I got this error message only on the simulator. On real device, i got another one :

在此处输入图片说明

You can see that i changed the app id from last time. I just create another facebook app (and i changed the bundle id as well)

Of course i double check that app id and bundle Id are same from my ios app and in the facebook app settings ... so why does it say that the app id is invalid ?

Attached my Facebook app settings for reference!

  • The Secure Canvas URL - Should have a valid link starting with https://
  • Canvas URL - Should have a valid link starting with http://

在此处输入图片说明

I don't think the issue is about the URL Scheme into the plist file.

In this related post , you can see the redirect_uri has to be set to a full URL when it's provided to redirect the user to after the login process is done. But I Think the redirect_uri has not to be set logging in by Facebook from an iOS app.

From my point of view, there are two ways to explore resolving this issue:

  1. Disable the FB option: embedded browser OAuth option
  2. Your plist file seems not to provide the FacebookDisplayName key which is now required. See the Facebook iOS SDK Getting Started page for this.
If you are using Facebook SDK, you don't need to bother yourself to enter
anything for redirect URI on the app management page of facebook. Just setup a 
URL scheme for your iOS app.
The URL scheme of your app should be a value "fbxxxxxxxxxxx" where xxxxxxxxxxx is
your app id as identified on facebook.
To setup URL scheme for your iOS app, go to info tab of your app settings
and add URL Type.

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