I am using the following graph api endpoint to seek the access token at the server side of my app for the given authorization code.
https://graph.accountkit.com/v1.1/access_token?grant_type=authorization_code&code=authorization_code&access_token=AA|facebook_app_id|app_secret
As mentioned in the Account kit docs for the access_token parameter I have concatenated the following:
"AA" + app id + app secret
Still I am getting Bad Request as response and following error is received:
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190,
The error was that I was using my app_secret, there is a separate secret for account kit, that you can find in your Account Kit dashboard. Use that secret for making request
Related
I am trying to connect a bot to Facebook messenger, using Facebook developer tools.
https://developers.facebook.com/
I've created the Facebook app, and it's sent me the webhook to my server. However, when trying to call the Graph API when sending a message back to the user, I receive the following error:
FacebookMessaging:400 : {
"error": {
"message": "(#2) Service temporarily unavailable",
"type": "OAuthException",
"is_transient": true,
"code": 2,
"fbtrace_id": "AIWsRyUmPFnySGwb1Rgl4P6"
}
}
POST API,
https://graph.facebook.com/v10.0/page-id/messages?access_token=token
JSON
{recipient:{id:"id"}, message:{ text:"message"}}
I suspect it could be because my app is unreleased, but I'm trying to test it beforehand. Is there any other explanation for this, or how are you suppose to test an app before releasing it?
The same code is working for an older Facebook app that is released.
The issue was that the API call was missing the access token. Stupid mistake, but unusual error for missing the access token.
I already try and reproduce this problem. May be you use wrong access_token in this case. When you want to send the message by page, use should use page access token instead of user access token
Check out the diff here: https://developers.facebook.com/docs/facebook-login/access-tokens/
And flow here for get page access token: https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens
It is clearly return you the response with type as OAuthException. If you find this error type in facebook garph api error handling documentation. You can see the first line of error codes is OAuthException. Also it is written there the resolution of this type of error in what to do column is, If no subcode is present, the login status or access token has expired, been revoked, or is otherwise invalid. Get a new access token.
If a subcode is present, see the subcode.
Well it is nice to see you get the answer on your own.
I am using Facebook Ads Insight API with a user token at the moment, but this user token expires (every hour for temporary token, and every 60 days for extended token) and I need to update it manually in my environment. Is there a way to use an app token to permanently allow access to the AdsInsight API? Otherwise, what's a programatic way to refresh the user token? (FYI, I use airflow to store the token in admin/connections)
For now my URL request is :
https://graph.facebook.com/v8.0/act_<SECRET_AD_ACCOUNT_ID>/insights?access_token=<SECRET_TOKEN>=ad_id,ad_name,clicks,unique_clicks,inline_link_clicks,unique_inline_link_clicks&time_range={'since':'2021-01-01','until':'2021-01-05'}&time_increment=1&level=ad
When the <SECRET_TOKEN> is
a user token : Data is generated correctly
an app token I get an error. (See bellow)
Error when using app token:
{
"error": {
"message": "Unsupported get request. Object with ID 'act_<SECRET_AD_ACCOUNT_ID>' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "<SECRET>"
}
}
The user tokens last 60 days, but there is a way to automatically update them through the API. Make a GET call to the following endpoint every < 60 days to refresh your user token.
oauth/access_token?grant_type=fb_exchange_token&client_id=<APP_CLIENT_ID>&client_secret=<APP_SECRET>&fb_exchange_token=<USER_TOKEN>
I was using access_token from FB AccountKit, but it seems that the access token from facebook account kit are not the same as Facebook's Graph API access token
Output from https://graph.accountkit.com/v1.1/me?access_token=THE_ACCESS_TOKEN shows correctly
"id": "1581612245187273",
"phone": {
"number": "+628979291xxx",
"country_prefix": "62",
"national_number": "8979291xxx",
},
When I use the same id from above as userID and THE_ACCESS_TOKEN as accessToken using Facebook SDK
fb.Get(`/` + userID, fb.Params{
`fields`: `name,email,birthday,gender,hometown,languages,location,religion,picture`,
`access_token`: accessToken,
})
It shows:
"error": {
"fbtrace_id": "GKBnPt6ZdMm",
"message": "Malformed access token",
"type": "OAuthException",
"code": "190",
},
Is my assumption correct? (that AccountKit access token is not the same as Facebook Graph API token)
How to get the facebook user information when you have only account kit access token? or it's not possible at all?
Account Kit uses a different graph from the Facebook graph and different access tokens. Accounts created with Account Kit are not linked to Facebook accounts. You can use the Account Kit access token to query the Account Kit graph API to find the phone number or email and accountID.
I would like to integrate my APP with some existing groups in Facebook.
So, for that, I would like to be able to read people's posts.
I have tried the following HTTP request to Facebook's graph API:
http://graph.facebook.com/v2.5/192992880732335
But it responds with the following:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104,
"fbtrace_id": "By+n1YSvvrI"
}
}
How can I get an access token to a specific group?
It is pretty ease to get all the feeds from that group.
Just add the access token from some user and your are done:
https://graph.facebook.com/v2.5/192992880732335/feed?access_token=<ACCESS TOKEN>
To get the access token, it is just a matter of calling
FB.getAuthResponse().accessToken
after user's login.
I can't get the list of my test users with my app access token. First I get the app access token with the following graph api call:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
which succeeds, I get an access token in the format
APP_ID|SomeRandomCharacters
Now I try to get my list of test-users using the following graph API call:
https://graph.facebook.com/APP_ID/accounts/test-users?access_token=APP_ACCESS_TOKEN
however, I get a "bad URL" error in my iOS code.
If I try to go to that address directly in a browser I get HTTP 400 Bad Request and if I try it in the Graph API explorer, I get
{ "error":
{ "message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
Check your app isn't defined as 'Desktop/Native' - if it is, your app secret is considered untrusted for API calls that can change the app's settings (including Test Users)
The assumption is that the app secret has been distributed with your native app and can't be trusted.