Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook redirect url issue OAuthException

Tags:

My app was working well for long time, but now I am getting the error from Facebook saying:

Content: {"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}}

https://www.facebook.com/dialog/oauth/?client_id=163840537126360&redirect_uri=http://mycloud.niranjan.com/facebook/callback//empty/?vTitle=Facebook&scope=email,sms,user_about_me,friends_about_me,user_activities,friends_activities,user_birthday,friends_birthday,user_education_history,friends_education_history,user_events,friends_events,user_likes,friends_likes,user_location,friends_location,user_photos,friends_photos,user_videos,friends_videos,user_relationships,friends_relationships,user_status,friends_status,user_checkins,friends_checkins,read_stream,publish_stream

Can anyone suggest a solution for this one?

like image 508
Niranjan Sagar Avatar asked May 15 '13 10:05

Niranjan Sagar


People also ask

What does it mean when Facebook says OAuthException?

OAuthException: If you receive an OAuthException error, it means that Edgar doesn't have the correct permissions to access your Facebook accounts right now. The password may have been changed on Facebook or Facebook may have reset your security session.

How do I redirect a URL on Facebook 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.

How do I get Facebook valid OAuth redirect URIs?

1. Log in to the Facebook for Developers center, and proceed to My Apps / Facebook Login (steps 1-3 above). 2. In the Valid OAuth redirect URIs field, type the redirect URI for your website and then press ENTER.


2 Answers

I realize this is 6 weeks late, but I figured I'll post this here since I found a fix that worked for us. Had the same issue and after trying to encode the return url (which did not work), I realized that we were building our URL like:

$url = "http://example.com/"; $redirect_script = "/cgi-bin/redirect.cgi";  $redirect_url = $url . $redirect_script; 

However this resulted in a return URL that looked like http://example.com//cgi-bin/redirect.cgi -- note the "//" after example.com. When I removed the double-slashes from this URL, it worked again. OP, I see that your redirect URL has the same thing in /facebook/callback//empty?etc which I believe is what's messing it up.

like image 50
mkania Avatar answered Sep 20 '22 17:09

mkania


In my case I was using http://127.0.0.1:8000 - However FB changes that automatically to http://127.0.0.1:8000/ in the OAuth redirect to deal wihh passing query params. Changing my URL in my code to have an end slash solved the issue for me. I suspect they are storing the final useable version and comparing that to the 2nd request.

like image 44
cyberwombat Avatar answered Sep 16 '22 17:09

cyberwombat