pavelk2 / social-feed

JavaScript plugin that shows a user feed from the most popular social networks
http://pavelk2.github.io/social-feed-example/
MIT License
963 stars 304 forks source link

Access tokens for Facebook #330

Closed vushe closed 5 years ago

vushe commented 6 years ago

Hello,

could anyone kindly shed light on how to get access token for a Facebook feed?

Is the token available in example permanent and unlimited for all of us utilizing social-feed.js? I recently tried to obtain a new token from Facebook and, [how I got it], they demand app review to grant us permission to get feed.

vushe commented 6 years ago

And default token doesn't work anymore, of course. I suggest either not to confuse people with Facebook support or provide a clear instruction on how to get a token.

HartLarsson commented 6 years ago

Hi, as usual to get "APP_ID" and "APP_SECRET" you need to create an APP like explained here: http://www.bloggingshiksha.com/how-to-get-app_id-and-app_secret-key-for-facebook-applications/

Keep in mind that Facebook has changed API version so you need to edit the socialfeed.js script and change the script as explained here (frm v2.4 to v2.12) https://github.com/pavelk2/social-feed/issues/326

vushe commented 6 years ago

Thanks for reply and instruction! I followed it, but, unfortunately, no luck. Below is the message returned when using API v2.12.

I asked Facebook for necessary permissions, but request rejected. Note that app token of social-feed.js is basically working fine (unless (#4) Application request limit reached is returned).

Message:

{
    error: {
        message: "(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.",
        type: "OAuthException",
        code: 10,
        fbtrace_id: "H+MhBEqBn09"
    }
}
martijngastkemper commented 6 years ago

Do you still have this problem after the update to Facebook V2.12?

vushe commented 6 years ago

Well, as I mentioned before, I have trouble with v. 2.12 as well.

I can only imagine that Facebook's policy for new tokens (or new developers) is changed. Old tokens are still working, however newly generated ones aren't with message returned:

(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.
mistafi commented 6 years ago

You are definitely not alone. Since the update to v3.0, I have tested a handful of newly generated tokens and none of them work.

kierweb commented 6 years ago

Looks like new keys require an "App Review" - see "Page Public Content Access" at the bottom of this page .... https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS

vushe commented 6 years ago

Yeah, after one-day review my app was rejected completely. For some rights they even ask you to upload videos. So I cannot fetch data even for the group I'm administrating.

Can it be related to GDPR?

Namstel commented 6 years ago

Maybe GDPR, probably Cambridge Analytica scandal. We're also running into this problem.

mistafi commented 6 years ago

After you submit for review, you are asked to select permissions. "Page Public Content Access" seems appropriate. Then you are prompted with this:

Details for Page Public Content Access Please explain how you are using Page Public Content Access to enhance the experience of your app.

Your app doesn't have any platforms listed. You'll need to add at least one platform in Settings before you can continue.

What platforms does your app use Page Public Content Access on? Web Mobile Other

Upload screencast We need to see your app using Page Public Content Access so we can see that it doesn't violate our policies. Upload a video screencast walkthrough using any method, (even recording with your phone).

You must show: How a person logs in with Facebook How a person sees this feature used in your app

Drag your screencast file here to upload Choose a file to upload...

Need help with screencasts? See examples and instructions here

Before you can submit for review, complete the following: Please provide a reason for why you are using this feature. Please provide instructions for how to reproduce this feature. Please provide a screencast that shows how this feature is used in your app

mistafi commented 6 years ago

But yet...there is also this:

Which permissions require review? Review is not required to ask for the two basic permissions: public_profile and email. Review is required to ask for any other permissions when people log into your app

So why aren't the tokens working? (thinking out loud and hoping for an answer)

Edited: Facebook permissions are confusing. They do not mean what you think they mean.

It appears we need both the "user_posts" and "Page Public Content Access" permissions to be granted.

I'm currently working on submitting one of these reviews and will report back.

kierweb commented 6 years ago

Noticed this bit ..

"While testing and before submitting for review, your app may only access content that is available on a Page that you own. If you want to access public content on other Pages, you must submit this feature for review."

So how do you get the app to own a page!?

mistafi commented 6 years ago

Possible fix, tested and currently working: go to

https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me%2Ffeed&version=v3.0

and grab the token it generates from here.

Also noted in #337

vushe commented 6 years ago

Thanks @mistafi. Unfortunately, token generated is temporary and valid just for a few hours.

mistafi commented 6 years ago

Thanks @vushe. I suspected it might be, but I couldn't find anything in the documentation about the time limit. Would you mind pointing me in that direction?

Edited: Found the expiry. Snap.

vushe commented 6 years ago

Just in case, you need to click small lightblue info button on the left.

image

I suspect this plugin is dead for Facebook :(

kierweb commented 6 years ago

Not just this plugin, any plugin which uses Facebooks API system!

mistafi commented 6 years ago

Does anyone know how we get the server side social feed piece to work?

https://github.com/pavelk2/social-feed-server

/facebook?url={the facebook graph request url without access_token and without ?callback} /instagram?url={the instagram request url without client_id and without ?callback} /google?url={the google + request url without access_token and without ?callback}

vushe commented 6 years ago

Example: https://graph.facebook.com/v2.12/PAGE_ID/posts?fields=id,from,name,message,created_time,story,description,link,picture,object_id&limit=LIMIT&access_token=TOKEN&callback=

mistafi commented 6 years ago

I'm having some trouble forming the URL based on this and figuring out how this fits in with the current plugin.

I've tried this, but not getting a return:

https://www.facebook.com?url=https://graph.facebook.com/v2.12/PAGE_ID/posts?fields=id,from,name,message,created_time,story,description,link,picture,object_id&limit=3

vushe commented 6 years ago

Why don't you remove this https://www.facebook.com?url=? The link I posted previously should return a json object.

mistafi commented 6 years ago

Hey @vushe, thanks for the direction. I tried using the call without the token and callback. Instead of a JSON object, I received Oauth errors. It still says you need a token.

Facebook. Sigh. lol

vushe commented 6 years ago

It's worth mentioning that juicer.io still works fine with Facebook.

They have free plan with basic restrictions. Maybe for someone like me this is a good substitute for social-feed.js. Paid plans are quite irrelevant for basic users but normal for companies. But good point is that you don't need to deal with tokens. Everything's primitively simple.

Feed example is here.

vushe commented 6 years ago

I'm not with Facebook anymore, but reportedly API works fine now. https://github.com/pavelk2/social-feed/issues/337

Closing.

PauloPeres commented 5 years ago

Hi Guys.... I Made a video on how to get the Access token if you are doing this for a Facebook Fanpage. i Hope it helps.

https://youtu.be/--vfXv6OmTE

kierweb commented 5 years ago

These access tokens are only valid for a couple of hours. "Expires | 1533722400 (in about an hour)"

HartLarsson commented 5 years ago

@PauloPeres your method is wrong you get a temporary access token that is valid for a limited time. Is good for fast debugging. For a permanent TOKEN you need to create a Facebook APP and inside the APP use the ID/TOKENS created.

PauloPeres commented 5 years ago

Shit I'm doing a job for a client and Facebook does not accept my application