I try to get an access_token like this documentation : https://developers.facebook.com/docs/authentication/server-side/
but it does not work !
I have this error :
{
"error": {
"type": "OAuthException",
"message": "Error validating verification code."
}
}
In the documentation it says we can use :
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE
client_id is my app_id
client_secret is the App secret
redirect_uri is the url of the website (Site URL in app configuration) (I tried with / and without at the end)
So my url is :
https://graph.facebook.com/oauth/access_token?client_id=14588084****&redirect_uri=http%3A%2F%2Fwww.mywebsite.com&client_secret=693ce9538e1f14e0*********&code=AQCVmlM9peMiL8Pv3mdi7c3FifwGLQDECdtN0oGMW4I6cisebeawDdSHP_crQlhsZxHKDOFT6zOrqeaoiL2pkQSkqAvwoPZdw0o1uCoLpUVjchghgfhgfhEXb2XS3UBD7iEc8eZ_YLF0cbVWL5i58sj3Rsr9vVFtfYwfghghgfhgfTkwajGcRp9n-lWWcepxghgIwzMMYLv8e__iDoMDiSNg
It's been ages since I last coded a Facebook app. Not sure if this will help: Facebook access token and AJAX calls
Related
I want to access my full details using facebook api . I am using postman client for this and hit api as
URL : graph.facebook.com/v2.2/me
METHOD : GET
HEADER PARAMETER :
AccessToken : djbjd
AppID : dsdmds
AppSecret :sdkkd
Now I get response :
STATUS : 400 Bad Request and Response
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "AQt0krgrd2U"
}
}
Can anyone tell me how I can hit facebook api using postman client .
You only need one GET parameter for this, the access_token parameter. It must be a valid User Token or Page Token.
You can also just try this in the browser directly: https://graph.facebook.com/me?access_token=xxx
I've been using Bearer Token to input the access token on Postman Client. The cool thing about it is you can add it to the folder and have every query inside the folder inherit it from the parent.
This lets me focus on the call and use each folder as an environment for calls related to the same object Page, App, Messenger and other tests
I want to read the user's apprequest-id. I've already finish the function below:
get server token:
url = "https://graph.facebook.com/oauth/access_token?client_id=#{app_id}&client_secret=#{secret_key}&grant_type=client_credentials"
then, i built the function that sending user_token to server as {client_access_token}
So, I call this function to get AppRequest as json
url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?input_token=#{client_access_token}&access_token=#{server_access_token}"
And i got this error:
{
"error": {
"message": "(#15) Requires session when calling from a desktop app",
"type": "OAuthException",
"code": 15
}
}
At first, I think that there are something wrong with the URL calling or access token, but I've already test another graph api such as "/me/friends" and "/me/?fields=installed" with the same input_token and access_token. And, it works normally. Please help.
This problem has been solve by using {client_access_token} as access_token :)
url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?access_token=#{client_access_token}"
There is wonderful tutorial how to use OAuth2 api to be authenticated by github. But if I want to use same api for facebook. I tried following and end up with error. So how can use OAuth2 api for facebook?
fb.client.id=79756xxxxxxxx
fb.client.secret=205adxxxxx
fb.redirect.url= "https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s"
// eventually url is filled as
https://graph.facebook.com/oauth/access_token?toeken&client_id=797565xxxx&redirect_uri=http://localhost:9000/_oauth-callback&client_secret=email&code=e3887ea3-3319-4462-a3b1-xxxxx
// get this error
{
"error": {
"message": "Invalid verification code format.",
"type": "OAuthException",
"code": 100
}
}
Update after updating the request url as
fb.redirect.url="https://graph.facebook.com/oauth/authorize?client_id=%s&redirect_uri=%s"
I managed to get facebook's login prompt. After submitting fb credential my redirect url is called as
http://localhost:9000/_oauth-callback/?code=AQD72MtTesmEIoQty3c0ZTC3a211egWR0pvVcLGhb6lB2T6TslG7r99IouP6KbE4oDYCl7n0_imyI0zxe-8Nb2CUDsRN5pEyQ_Pk6JRwy0JRy3T27kbDJ9DRcr11NrDdlZtNK3tOe6kfTdVQm52YXMTF7L9Kq3N6z0ZIBbVxsizvWZ00kVUL2YkSdnh5mpx4ofKaTgd0pHNhE9X33mBdzS7Evu_R0yW8XqgZFfvEPFE3f1e9qdrbrhwHaj1kfZyk6NigDBpnyZ5CgtzFTDpLHZVKQXCWDNzfqMwlxYuV2amTJUEgq77_HzxnDD3njvU4dJK0lrpVrkimqMeldCFEHzbV#_=_
I don't know how to use this code = XXX. Don't even know what does this code mean? How can ask user public profile info after my redirect url is called? Please let me
I went to https://developers.facebook.com/tools/explorer?method=GET, set up there ID of my Facebook page, set up there the correct permission for posting statuses on my FB timeline and generated access token.
Then I wanted to extend this short-live token on the long-term (60 days long valid token). So I did following - I put this URL to the browser:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID_OF_MY_FB_APP&client_secret=SECRET_ID_OF_MY_APP&grant_type=fb_exchange_token&fb_exchange_token=GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP
and in the browser I saw this error message:
{
"error": {
"message": "The access token does not belong to application APP_ID_OF_MY_FB_APP",
"type": "OAuthException",
"code": 1
}
}
Which is weird, because the APP_ID of my Facebook app is correct, I've tried to post on the wall of the Facebook page and it was working.
But when I try to get extended access token, I am getting the error above.
What's wrong with the access?
Thank you
This almost certainly means what the error says, which is that GENERATED_ACCESS_TOKEN_FROM_THE_FIRST_STEP is not actually from the app ID that you're using in the APP_ID_OF_MY_FB_APP parameter
Check the access token you're trying to extend in Facebook's Debug Tooland ensure it was actually generated for your app
Your AppID param is not the same to the AppID in developers.facebook.com
Is it possible to retrieve Facebook page statuses using an app access token?
According to the documentation I could use "any valid access_token or user access_token" but when I try to use the application access token I'm getting the following message: "A user access token is required to request this resource.". Am I generating the app access token in a wrong way? Is there anyway to access the statuses of a public Facebook fan page without a user?
It seems that a user access_token is required to query this connection.
Tried without any access_token in the Graph API Explorer on redbull page and the result was:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
But after providing an app access_token:
{
"error": {
"message": "A user access token is required to request this resource.",
"type": "OAuthException"
}
}
This is a bit misleading!
Don't know if your still facing this issue. But here's a workaround :
By asking the graph API, you have this issue, but by using the FQL langage, it works perfectly with an App ID!
Here's an example for the 'PSG' page :
https://api.facebook.com/method/fql.query?query=SELECT post_id, type, attachment, message FROM stream WHERE source_id IN(SELECT page_id from page where username='PSG')&access_token=YOUR_APP_ACCESS_TOKEN
;)