[ACCEPTED]-Facebook OAuth: custom callback_uri parameters-facebook-oauth
I figured out the answer; rather than adding 4 additional parameters to the redirect URL, you 3 can add a state
parameter to the request to https://www.facebook.com/dialog/oauth
:
https://www.facebook.com/dialog/oauth ?client_id=MY_CLIENT_ID &scope=MY_SCOPE &redirect_uri=http%3A%2F%2Fwww.mysite.com%2Foauth_callback%3Ffoo%3Dbar &state=6234
That 2 state parameter is then passed to the callback 1 URL.
If, for any reason, you can't use the option 4 that Jacob suggested as it's my case, you 3 can urlencode your redirect_uri
parameter before passing it and 2 it will work, even with a complete querystring 1 like foo=bar&morefoo=morebar
in it.
I was trying to implement a Facebook login 16 workflow against API v2.9 following this tutorial. I 15 tried the solutions described above. Manuel's 14 answer is sort of correct, but what I observed 13 is url encoding is not needed. Plus, you 12 can only pass one parameter. Only the first 11 query parameter will be considered, the 10 rest will be ignored. Here is an example,
Request 9 a code via
https://www.facebook.com/v2.9/dialog/oauth?client_id={app-id}&redirect_uri=http://{url}/login-redirect?myExtraParameter={some-value}
You'd get a callback for your 8 url. It will look like
http://{url}/login-redirect?code={code-from-facebook}&myExtraParameter={value-passed-in-step-1}
. Note that facebook 7 would make a callback withmyExtraParameter
. You can extract 6 the value formyExtraParameter
from callback url.Then you 5 can request access token with
https://graph.facebook.com/v2.9/oauth/access_token?client_id={app-id}&client_secret={app-secret}&code={code-from-facebook}&redirect_uri=http://{url}/login-redirect?myExtraParameter={value-extracted-in-step-2}
Additional 4 parameter passed in step 1 after the first 3 query parameter will be ignored. Also make 2 sure to not include any invalid characters 1 in your query parameter (see this for more information).
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.