Martin Bories
Martin Bories

Reputation: 1117

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.

Upvotes: 6

Views: 6292

Answers (3)

Nacho Coloma
Nacho Coloma

Reputation: 7318

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

Upvotes: 1

Martin Bories
Martin Bories

Reputation: 1117

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?

Upvotes: 2

Jesse Chen
Jesse Chen

Reputation: 4928

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.

Upvotes: 1

Related Questions