Facebook login: Please make sure your redirect_uri is identical to the one you used in the OAuth dialog

18,080

Solution 1

I believed you have used different redirect_uri in your facebook app settings and Oauth API code. thats why you got this error.

For facebook login you must set same redirect_uri into both place.

Solution 2

You can set redirect URI in Go to https://developers.facebook.com/apps Select your app.

Under Products > Facebook Login > Settings

  • Enable Embedded Browser OAuth Login
  • Set Valid OAuth Redirect URIs

You can Validate Redirect URI with Redirect URI Validator.

You can only use https URIs. Also set App Domain in Settings > Basic > App Domains

Try / at the end of redirect URI

In my case I was using https://localhost everywhere but somehow when getting access token specifying https://localhost/ worked.

Solution 3

As absurd as it sounds, verify you're using the correct app_secret.

Facebook will give you this instead of just saying "invalid secret" in the response

Share:
18,080
Uffo
Author by

Uffo

Updated on July 26, 2022

Comments

  • Uffo
    Uffo almost 2 years

    So I'm out of ideas, I don't know what to check or debug anymore, but on the exception I get this:

    string(188203) "Facebook\FacebookAuthorizationException Object
    (
        [statusCode:Facebook\FacebookRequestException:private] => 400
        [rawResponse:Facebook\FacebookRequestException:private] => {"error":{"message":"Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request","type":"OAuthException","code":100,"fbtrace_id":"DqCCKoiN0r4"}}
        [responseData:Facebook\FacebookRequestException:private] => Array
            (
                [error] => Array
                    (
                        [message] => Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
                        [type] => OAuthException
                        [code] => 100
                        [fbtrace_id] => DqCCKoiN0r4
                    )
    
            )
    
        [message:protected] => Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
        [string:Exception:private] => 
        [code:protected] => 100
    
  • Uffo
    Uffo almost 8 years
    where in app settings? @fire
  • Uffo
    Uffo almost 8 years
    Where in app settings?
  • Dharmesh Goswami
    Dharmesh Goswami almost 8 years
    @Uffo In Basic or Advanced settings, you can see callback URL option.
  • Uffo
    Uffo almost 8 years
    uh I have that now If I add facebook login, but still doesn't work
  • Dharmesh Goswami
    Dharmesh Goswami almost 8 years
    @Uffo Do you have 'https' in your redirect_uri ? If yes then change it to 'http' in both place.
  • Dharmesh Goswami
    Dharmesh Goswami almost 8 years
  • Naumov
    Naumov over 6 years
    I have similar problems but can't find when set this redirect_uri
  • Tom
    Tom over 4 years
    Adding the slash on the end fixed this for me (no slash was needed on the initial request)
  • Atul Yadav
    Atul Yadav about 4 years
    Finally after spending like an hour!
  • stefando
    stefando almost 4 years
    Can indeed confirm this is the case, I missed one character when copy/pasting the secret resulting into this error. Thanks for saving me some time!
  • Saikat Saha
    Saikat Saha almost 3 years
    please be more descriptive
  • Artem Areshko
    Artem Areshko over 2 years
    Adding a slash did work for me. Looks weird...
  • Miriam Arbaji
    Miriam Arbaji over 2 years
    Thank you!! you saved me
  • Dmitry Polomoshnov
    Dmitry Polomoshnov about 2 years
    strangely enough, it accepts redirect_uri without trailing / for oauth request, but requires / when getting token