$token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $app_secret . "&code=" . $code;
What is supposed to be the redirect_uri? I tried using this
'https://graph.facebook.com/oauth/authorize?client_id='.$app_id.'& redirect_uri='.urlencode($canvas_page).'&scope=email,read_stream,publish_stream';
but it returned with this error
{ "error": { "message": "Error validating verification code.", "type": "OAuthException" } }
Need help, Thanks in advance.
A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.
Basically, you can subscribe to updates that will tell you 1) if the user removed the app or 2) if the user removed permissions. You could use this to store the current permissions of the faceboook user. This way, if the user removed your app you would know that the access token is expired.
Go to your Facebook application dashboard
https://developers.facebook.com/apps
Select you application from the accordion menu to the left of the page.
There is a Value for Canvas URL(here it is 'http://localhost:7124' which point to a local server. )
The redirect url must be a url within this url(site). ie something like 'http://localhost:7124/home.aspx' or 'http://localhost:7124/main/home.aspx'
To get an access token follow the below steps
Issue a request to
https://www.facebook.com/dialog/oauth?client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&scope=read_stream
This will provide you with a user authentication code(CODE) to denote that the user is signed in.
Then with this code issue a request to
https://graph.facebook.com/oauth/access_token?client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&client_secret=APP_SECRET&code=CODE
which will provide you the access token in the format access_token=ACCESSTOKEN to the redirect url you have specified.
NOTE: Redirect Url must be a path inside the Canvas Url of the Facebook application and these requests should be submitted from the same domain pointed by the Canvas Url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With