how to query graph.facebook with postman? - facebook-graph-api

I'm using postman to query from Facebook Graph API. I'm trying next line:
https://graph.facebook.com/v2.8/me?access_token=my_access_token=<here is my user token>
and i get:
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "ASBwgp9xF/R"
}
}
I can't figure out alone the right syntax
the access token works at facebook graph api explorer.

You donĀ“t even need postman for this, just hit the URL in your browser.
This is the correct one:
https://graph.facebook.com/v2.8/me?access_token=<here is my user token>

Related

Instagram API graph stories

First I auth my user, which has role instagram Test Users, got access token by doint request to https://api.instagram.com/oauth/access_token Follow Getting Started guide.
Make a request to get user data https://graph.instagram.com/me?fields=username&access_token={{ACCESS_TOKEN}}
Everything OK, got 200 status and data.
Now tried to follow API Stories Docs
make a request to: https://graph.facebook.com/{{IG_ID}}/stories?access_token={{ACCESS_TOKEN}} (IG_ID is the ID I got from user data request) but doesn't work return invalid access token
{
"error": {
"message": "Invalid OAuth access token - Cannot parse access token",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "{ID}" //im not sure if important to hide
}
}
Now tried to use Explorer Api Graph (Tools->Explorer) I generate an access token (this token is generated with Facebook, not instagram), use this token and the ID (/me in Explorer API) in previous request and the response is:
//https://graph.facebook.com/{{ID}}/stories?access_token={{TOKEN}}
{
"error": {
"message": "(#100) Tried accessing nonexisting field (stories) on node type (User)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "{ID}"
}
}
Maybe I'm misunderstanding the guide, anyone have worked with API?
Hmmm... Does API works with private/public accounts? Or only if account is Business/Content Creator might use this?

Making facebook Test Users friends using Facebook Graph API

I have 2 test users in facebook.
I want to make them friends using Facebook Graph API:
https://graph.facebook.com/v2.6/user1_id/friends/user2_id?access_token=user1_access_token
method: post
I get error:
{
"error": {
"message": "(#33) This object does not exist or does not support this action",
"type": "OAuthException",
"code": 33,
"fbtrace_id": "A7EHydY_B4x......."
}
}
Can someone please help?
Thanks.
https://developers.facebook.com/docs/graph-api/reference/v6.0/test-user:
An app access token is required to update these fields for any test users associated with that app.
You need to use your app access token for this, not a user token.

Can I get the access token without login?

Can I get the access token without login? As I need to get the ratings by below API and this API i required access_token.
https://graph.facebook.com/v5.0/{page-Id}/ratings?access_token={page_access_token}
Below steps I have done it to achieve the ratings.
First API Call
https://graph.facebook.com/oauth/access_token?client_id={client-id}&client_secret={client-
secret-id}&grant_type=client_credentials
Second API calls
https://graph.facebook.com/debug_token?input_token={user_access_toke}
&access_token={generated_access_token_from_ouath}
Error:
{
"error": {
"message": "(#100) The App_id in the input_token did not match the Viewing App",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AFBYAMTvW5W65Ur3gUXa_0e"
}
}
Can you please help me out to generate the access token so I can get the rating and reviews.
For Ratings, you need to use a Page Token. A Page Token can only be generated with a User Token, and you do need to login for that. Without any login, Facebook does not know if you own the Page - which is required to read the Ratings with the API.
Information about Tokens and how to generate them:
https://developers.facebook.com/docs/facebook-login/access-tokens/
https://www.devils-heaven.com/facebook-access-tokens/

How to handle access token in loopback

I am new to loopback and I would like some guidance on how to enable authorization for all API path and what is the use of access token.
I have logged in with registered username,password using POST/Users/login api and got access token in reponse,related screen shot
https://i.stack.imgur.com/B0EFQ.png.
And i set that token as below
https://i.stack.imgur.com/26ADI.png
And i tried GET/Users api but iam getting authorization required error
{
"error": {
"name": "Error",
"status": 401,
"message": "Authorization Required",
"statusCode": 401,
"code": "AUTHORIZATION_REQUIRED",
"stack": "Error: Authorization Required\n at C:\Users\prem\Desktop\test\testauth\node_modules\loopback\lib\application.js:399:21\n at C:\Users\prem\Desktop\test\testauth\node_modules\loopback\lib\model.js:322:7\n at C:\Users\prem\Desktop\test\testauth\node_modules\loopback\common\models\acl.js:472:23\n at C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:3694:9\n at C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:356:16\n at iteratorCallback (C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:936:13)\n at C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:840:16\n at C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:3691:13\n at apply (C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:21:25)\n at C:\Users\prem\Desktop\test\testauth\node_modules\async\dist\async.js:56:12\n at C:\Users\prem\Desktop\test\testauth\node_modules\loopback\common\models\acl.js:454:17\n at C:\Users\prem\Desktop\test\testauth\node_modules\loopback\common\models\role.js:273:21\n at _combinedTickCallback (internal/process/next_tick.js:67:7)\n at process._tickDomainCallback (internal/process/next_tick.js:122:9)"
}
}
but its working for POST/Users/logout api with 204 as status code.
Please share any guidance how to add access token in authorization header
Simple typo, you are using accesstoken as argument in the request, but the keyword is access_token
Correct request:
http://localhost:3000/api/custs/logout?access_token=REPLACE-WITH-YOUR-ACCESS-TOKEN

How to publish a new post to facebook wall?

My app have been approved for publish_actions permission and I want to publish to user's wall behave my user. I tried to call the graph API like this:
https://graph.facebook.com/v2.7/me/feed?access_token=<token>&method=post&message=Hello
I read the facebook documents and It says A user access token with publish_actions permission can be used to publish new posts.
But actually I can't publish the message to user's wall. What I receive is:
{
"error": {
"message": "Invalid OAuth 2.0 Access Token",
"type": "FacebookApiException",
"code": 190,
"error_subcode": 1732004,
"is_transient": false,
"error_user_title": "Invalid Access Token",
"error_user_msg": "Invalid access token received.",
"fbtrace_id": "<trace code here>"
}
}
Do I make any mistake?
Update: Add screenshot of my token debugger information
This worked fine for me: https://graph.facebook.com/me/feed?access_token=xxx&method=post&message=test
Make sure the Access Token is valid and includes the publish_actions permission, you can test it here: https://developers.facebook.com/tools/debug/access_token/