-2

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.

Maneesh Rao
  • 184
  • 4
  • 23
  • You need to get a user token from a page admin first, and that step can not be automated - you need the login dialog for that. – 04FS Jan 15 '20 at 11:01
  • How can I login at the server side? – Maneesh Rao Jan 15 '20 at 12:38
  • You can’t. Getting a user access token requires user interaction. – 04FS Jan 15 '20 at 12:39
  • I need to get the reviews of many Facebook pages and show to our app on dashboard. Suppose someone is looking our dashboard then why they need to user interaction to see the dashboard? Is there any way to do it? – Maneesh Rao Jan 15 '20 at 12:44
  • They don’t need user interaction to view your dashboard, no one said that. Getting a user access token requires user interaction. – 04FS Jan 15 '20 at 12:46
  • I got the user access token from Facebook admin. and put thee user_access token in this api. but getting same error. https://graph.facebook.com/debug_token?input_token={user_access_token} &access_token={generated_access_token_from_ouath} – Maneesh Rao Jan 15 '20 at 12:57
  • And what is unclear about the error message? – 04FS Jan 15 '20 at 12:59
  • Error message: "(#100) The App_id in the input_token did not match the Viewing App" – Maneesh Rao Jan 15 '20 at 13:00
  • I did not ask you to repeat what you already said, I asked you what is unclear about that message to you. – 04FS Jan 15 '20 at 13:02
  • Btw., your first API call is not even getting a user access token. – 04FS Jan 15 '20 at 13:03
  • From first API call I am getting the access token which will required to get the page access token. I am following below documentation. https://stackoverflow.com/questions/5406859/facebook-access-token-server-side-validation-for-iphone-app/16092226#16092226 – Maneesh Rao Jan 15 '20 at 13:06
  • That first API call does NOT generate a _user_ access token. What you are following there describes the process of debugging a user access token you already _have_ at this point, nothing about this has to do with _getting_ a user access token in the first place. – 04FS Jan 15 '20 at 13:11
  • @04FS Thanks for your reply. – Maneesh Rao Feb 27 '20 at 07:23

1 Answers1

-1

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:

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • Can you please help me via steps by steps as I am following above code? – Maneesh Rao Jan 15 '20 at 12:39
  • I am not telling you to write a code. I am just asking the Steps. What I need to show the Facebook reviews in our app dashboard. I need to get the reviews of many Facebook pages and show to our app on dashboard. Suppose someone is looking our dashboard then why they need to user interaction to see the dashboard? Is there any way to do it – Maneesh Rao Jan 15 '20 at 12:46
  • why the downvote? please explain so i can improve my question if needed. btw, i added a link to the official docs, they explain how to generate different tokens very well. – andyrandy Jan 15 '20 at 14:08
  • I have read the documentation, I need to get the ratings of different Facebook business page on our dashboard. So, I just asked you a question that how can we get the ratings. I have already written a code but as my current flow this is not working. So need help from your side. I am not telling that you should write a code for me. But If you know about Graph API then you can instruct me how we can achieve the ratings of other Facebook company. – Maneesh Rao Jan 16 '20 at 05:20
  • your api call is correct, you are just not using the correct page token. of course you need a page token of the specific page - you can also use /me/ratings with the page token, because using the page id in the api call is pointless. the page token is bound to one specific page. so i am not sure what else to tell you, to be honest. of course you have to manage the page if you want to get the ratings, if that is another issue. how to get a page token is in the docs - see added link in my answer. – andyrandy Jan 16 '20 at 07:31
  • i have added another link about generating tokens. right now, you do not correctly generate a user token as 04FS pointed out in the comments. – andyrandy Jan 16 '20 at 07:33