FB exchange token api missing redirect_uri
Asked Answered
M

5

18

I am using the FB exchange token api like this :

https://graph.facebook.com/oauth/access_token?client_id={client_id}8&client_secret={client_secret}}&grant_type=fb_exchange_token&fb_exchange_token={one_hour_token}&redirect_uri=http%3A%2F%2Fotagz.cloudfoundry.com%2FfacebookCallback

I am getting the following error :

"message": "Missing redirect_uri parameter., "type": "OAuthException", "code": 191

I have my application URL : otagz.cloudfoundry.com

I know there is another question on the subject but there is no solution to it and it is from 2010.

Does anybody know what's wrong with the redirect_uri?

Thanks, Cristian

Merriweather answered 1/7, 2012 at 14:27 Comment(1)
This part of stackoverflow is supposed to be the official Facebook Technica Q&A. Am I assuming this right? If so, can somebody from facebook please give me an answer?Merriweather
G
15

Had the same problem, solved it by reoveing spaces from the url (i copied it from facebook website and there was a couple of extra spaces between the params)

Gav answered 17/10, 2017 at 12:12 Comment(2)
Yes, Same issue was for me!Bandbox
In my case they were line breaksKirin
D
13

If you're using CURL command-line tool - probably you have same problem as I had: just put the URL in quotes. See Facebook answer for this bug: https://developers.facebook.com/bugs/1374437326120797

I'm not sure that Facebook uses Stackoverflow as official communication way. You would get faster answer here: https://developers.facebook.com/bugs/

Disloyalty answered 21/8, 2013 at 7:15 Comment(0)
U
2

Try setting parameter grant_type to client_credentials. URL would go like this then: https://graph.facebook.com/v2.8/oauth/access_token?client_id=XXX&client_secret=XXX&fb_exchange_token=XXX&grant_type=client_credentials

Or to make it bit more readable:

$q = http_build_query(array(
    'client_id' => $app_id,
    'client_secret' => $app_secret,
    'fb_exchange_token' => $user_token,
    'grant_type' => 'client_credentials'
));
$url = "https://graph.facebook.com/v2.8/oauth/access_token?$q";
Uturn answered 9/1, 2018 at 5:0 Comment(1)
If I once create a long lived user token via Debugger took, can I save it in DB and use it on the above API END point to generate long lived token everytime?Intarsia
P
1

I was facing your issue but i manage to solve it with below method. It doesn't require redirection

lets assume you already got the short live access token

$accessToken;

$graph_url = "https://graph.facebook.com/oauth/access_token?client_id=".$your_app_id."&client_secret=".$your_app_secretkey."&grant_type=fb_exchange_token&fb_exchange_token=".$accessToken;

$result = file_get_contents($graph_url);

parse_str($result, $output);

echo $output[access_token];
echo $output[expires];  
Palladian answered 15/8, 2012 at 16:52 Comment(1)
I get an the same error using above method , which is the default from the docs ..{"message":"Missing redirect_uri parameter.","type":"OAuthException","code":191}Jebel
V
-1

This might help some one

Don't put the closing forward slash (/) after the url

Correct URL = https://graph.facebook.com/oauth/access_token?client_id=....

Wrong URL = https://graph.facebook.com/oauth/access_token/?client_id=...

Vanya answered 29/9, 2021 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.