Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook - OAuth Token - redirect_uri isn't an absolute URL

... but it is!

I am calling the facebook API with the following link in order to receive my access token:

https://www.facebook.com/dialog/oauth?client_id=myclientid&redirect_uri=http%3A%2F%2Fmydomain.org%3A8080%2FServer%2FFacebookAuthenticationVerificationServlet&scope=manage_notifications,offline_access,read_mailbox,read_stream,publish_stream

What am I doing wrong?

Facebook answers with the following error:

message: redirect_uri isn't an absolute URI. Check RFC 3986.
type: OAuthException
code: 191

It shouldn't have anything to do with it, but I am using java's URLEncode.encode() to encode the URL into UTF-8. I compared the result with that one from JavaScript's encodeURIComponent() and didn't find any difference.

EDIT: Do I have to set the domain into my configuration? I can't locate it on "App Domains" (because facebook doesn't allow me to add domains there with port configuration) but I set the domain as "URL of my website".

EDIT2: The unencoded redirect uri: http://mydomain.org:8080/Server/FacebookAuthenticationVerificationServlet

EDIT3: This has nothing to do with the :8080. I tested it with a php-script (URL was like bla.domain.org/myphp.php) and sent the code by the php script to the tomcat server, but the error persisted.

like image 364
Martin Bories Avatar asked Nov 27 '12 15:11

Martin Bories


3 Answers

Okay, it turned out I misunderstood the OAuth protocol. I was fetching the authorizationCode that THEN leeds me to the accessToken.

But I wasn't able to fix that error in specific. I just redeveloped the procedure and implemented auth-code and access-token separation and it works fine now.

Maybe unauthorizating the app and reauthorizating it @ facebook did fix it?

like image 193
Martin Bories Avatar answered Oct 03 '22 10:10

Martin Bories


Error code 191 for Facebook is

API Error Code: 191

API Error Description: The specified URL is not owned by the application

Error Message: redirect_uri is not owned by the application.

Make sure mydomain.org is in the App Domains field, and that the Website with Facebook login field is correct.

like image 40
Jesse Chen Avatar answered Oct 03 '22 10:10

Jesse Chen


You shouldn't encode redirect_uri. http%3A%2F%2Fmydomain.org is not understood as http://mydomain.org

like image 45
Nacho Coloma Avatar answered Oct 03 '22 10:10

Nacho Coloma