Topic-icon How to Get redirect_uri Parameter?

Active Subscriptions:

None
11 years 7 months ago #26976 by fb_1565926376
I've been trying to get an authorization code to access some user data, but I keep getting the following error:
{
   "error": {
      "message": "Missing redirect_uri parameter.",
      "type": "OAuthException",
      "code": 191
   }
}

And here is an example of the code I'm trying to run:
1. Get an access_token with the user_birthday permission:
https://graph.facebook.com/oauth/authorize?client_id=130816363274
&redirect_uri=http://www.example.com&scope=user_birthday
&type=user_agent

2. Try to get the current user's birthday:
https://graph.facebook.com/me?
fields=birthday&access_token=RESULT_FROM_STEP_1

I've done some Google searches and it looks like any URL on my site with the Facebook log in button should work as the redirect_uri, but it keeps failing. I've even tried encoding the URL properly, like so: https%3A%2F%2Fwww.example.com%2F

Any suggestions?
The topic has been locked.
Support Specialist
11 years 7 months ago #26978 by alzander
If this is your code:
https://graph.facebook.com/oauth/authorize?client_id=130816363274 
&redirect_uri=http://www.example.com&scope=user_birthday 
&type=user_agent
That looks to be the problem. The redirect_uri is invalid. It should look like either:
redirect_uri=http://www.example.com/?scope=user_birthday
redirect_uri=http://www.example.com/

The way you have it, there's no delineation between the parameters and the domain, and that's bad. Let us know if that helps, but if not, you know where we are!

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
11 years 7 months ago #27025 by fb_1565926376
Thanks Alex. With this code, I am trying to query a users likes and interests. With your help, I was able to get an active auth token (I think), but step #2 fails. Here's what I have so far...
Get an access_token with the user_likes permission:

https://graph.facebook.com/oauth/authorize?client_id=XXXXXXX&redirect_uri=http%3A%2F%2Fwww.example.com&scope=user_likes&type=user_agent

2. Try to query the current user's interests:

https://graph.facebook.com/me?

fields=interests&access_token=RESULT_FROM_STEP_1

But I get the following error when I run step 2:
{
   "error": {
      "message": "An active access token must be used to query information about the current user.",
      "type": "OAuthException",
      "code": 2500
   }
}

I have tried pasting in just the access_token from step 1, and the complete string after it which includes the expires_in and code values. No matter what, I get the error above. Any suggestions?
The topic has been locked.
Support Specialist
11 years 7 months ago #27057 by alzander
If you're using JFBConnect to let the user login, you shouldn't need to re-request or authorize the user to get new permissions. JFBConnect can handle that when they login. Then, we store the access_token in the database for the user as well as fetching a 'long-lived' one that works for 60-days. The access_token you'd get from the call above would last for about 2 hours and then expire, just so you know.

So, if you can, cut out the first step from above and then try to re-call the request to get profile info. If the user is already logged in using JFBConnect, you can even make things easier and simply call the following code:
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$fbUserId = $jfbcLibrary->getFbUserId();
$fields = array('interests');
$data = getUserProfile($fbUserId, $fields);

If you want to use your own authentication token, I'd recommend playing with the Facebook Access Token Debugger to see the details about your specific token:
developers.facebook.com/tools/debug/access_token/

Hope that helps!
Alex
The topic has been locked.