MMM
MMM

Reputation: 79

Facebook graph api get the user's infomation

I want to make a website which users can see their posted pictures on the page.

I have signed up for facebook API and have an app id and app secret.

https://graph.facebook.com/oauth/access_token?client_id={#}&client_secret={#}&grant_type=client_credentials

I send users to the oauth to get the user's access token but I don't know what to do next.

https://graph.facebook.com/v3.0/me?fields=id,name,posts&access_token={#}

I thought this would work but I had the error below "An active access token must be used to query information about the current user.",

Upvotes: 0

Views: 315

Answers (1)

mayank
mayank

Reputation: 543

The URL you are using to get the Access Token is actually an App Token API. To generate the Access Token Please replace

https://graph.facebook.com/oauth/access_token?client_id={#}&client_secret={#}&grant_type=client_credentials

with

https://www.facebook.com/v3.0/dialog/oauth?response_type=token&client_id={#id}&redirect_uri={#}&scope=publish_pages

add a redirection url here where the token is published.

OR

better option is to use the login button mentioned here.

https://developers.facebook.com/docs/facebook-login/web/login-button

Also you can read here about all Access Tokens

https://developers.facebook.com/docs/facebook-login/access-tokens/

Upvotes: 0

Related Questions