Never Expiring Facebook Page Access Token
Asked Answered
A

2

6

I have been trying to find a way to create a never expiring FaceBook Page Access Token. I have seen the option where you provide the AppID|AppSecret in place of the token however that requires you to submit the app for approval and facebook does not seem to understand concept of OTHER apps using the token. Regardless, see the answer below for how I found a way to do this.

Alto answered 28/11, 2018 at 0:25 Comment(11)
so...what is your question? stackoverflow is not a blog platform, it´s for questions. btw, there are no never expiring page tokens anymore afaik. even your screenshot tells you that it does in fact expire.Ity
So I reworded this to make you happy. Also, according to the actual Facebook Access Token tool, you are incorrect regarding not being able to get a never expiring token. Please see number 9 in my answer - which I do not have a screen shot of. "In the Access Token Debugger that will open up, click on the 'Extend Access Token' button at the bottom of the page. A new access token should be displayed and the text above it should say that it never expires"Alto
you may want to read this, it´s pretty new: developers.facebook.com/docs/facebook-login/access-tokens/…Ity
That is about short lived versus long lived tokens, not never expiring.Alto
yes it is. extended page tokens were never expiring earlier, but they are not anymore.Ity
No that is not what this post is about - it is about a page access token that never expires. Please see the screen shot I posted down below from the Facebook Access Token tool that shows that my token, generated using this method never expires.Alto
this may as well be a bug right now, as they changed it recently. did you try using the token for more than 60 days without refreshing?Ity
I can't really speak to whether or not there is a bug in a FaceBook product. All I can say is it is working onw and will continue to test through the 60 day point. I will update the post after the 60 days to see if it expires or not.Alto
This is a legitimate developer question for a real world problem. There are companies that want to extract their page insights data to load into a data warehouse using a scheduled script and a non-expiring token. There are some published workarounds to this question like rocketmarketinginc.com/blog/… and medium.com/@Jenananthan/… Being pedantic about whether these workarounds are a bug is not constructive.Spannew
Just an FYI - it is coming up on three months since I created this token and it is still working. I will actively watch and test it after the 90 days have expired to see if it truly is a non-expiring token.Alto
@luschn did it expire in 60 days?Gaffney
A
18

After piecing together many different solutions - I did this and it seems to work. I assume you only want a token for a single page and that you already have your Facebook app page setup.

  1. Get the ID of the page by navigating to it from a web browser, click on About link in the menu list down the left hand side of the page, then scroll to the bottom of the About information and you will see the Page ID display.

  2. Navigate to Facebook Graph API Explorer

  3. Remove everything after the API Version (in this case v3.2) on this line of the explorer
    enter image description here

and replace it with 123456789?fields=access_token where 123456789 is your page ID.

enter image description here

  1. Click the Submit button to the right hand side of the line you just entered the text into.

    1. You will receive a token back in the response at the bottom of the screen that looks similar to this:

{ "access_token": "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", "id": "1755746091324056" } where TTTTTTTT is your access token.

  1. Copy the token only (no quotes) out of the response and past it in the Access Token field at the top of the Page replacing the Access Token that was previously there.

enter image description here

  1. After pasting in the new access token click on the blue information icon to the left of the access token.

  2. In the Access Token Information dialog, click on the 'Open in Access Token Tool' button at the bottom right of the dialog.

enter image description here

  1. In the Access Token Debugger that will open up, click on the 'Extend Access Token' button at the bottom of the page. A new access token should be displayed and the text above it should say that it never expires.

enter image description here

I hope this helps.

PS - Here is what I see in Facebook's Access Token tool when I paste the token generated using this method into it. It says this token will never expire.

enter image description here

Alto answered 28/11, 2018 at 14:38 Comment(22)
Do you need to be page owner? Or page admin is enough?Calculus
NeverEndingQueue Not Sure -- I am both for my page.Alto
Facebook says that your app needs to have business permission ... which is a requirements I am not sure to understand at the app level. The tokens I am generating are only valid for two months doing this.Nehru
AsTeR, If you ensure you have the same scopes on the page as I show above and follow the steps I have outlined, you should be good to go. It has been over five months since I generated my token and it is still working fine.Alto
I have done all this, but it says that it expires in 2 months! @Nehru did you find a solution?Gaffney
@DanieleB no, but without being sure, it seems that the token is not actually expiringNehru
Daniele B - The two month token is the first token. It looks like maybe you only did to step 5. Try starting at step 6 using the page access token that expires in two month. Also remember this does not work for all types of Access tokens, only facebook app page access token.Alto
@GeorgeMCeaserJr actually I completely all stepsGaffney
Daniele B -- so in step 8 when you viewed the access token information, what expiration does it show? and you are using the access token that was generated in the last step when you clicked the "Extend Access Token" button correct?Alto
Step 8 shows the normal token expiration -- like an hour I think? Yes using the access token that is in the last step when you click the extend token. When I copied that token, and past it back into FaceBook's access token tool, I see the last screen shot which show that token never expires.Alto
Just tried this and it only extends it for 2 months.Pivotal
This will only work for pages. Are you shure you are using a page access token and not user or some other type?Alto
This seems to no longer be working. For some reason facebook revoked all of my login sessions which also invalidated my "never expiring" token. I tried making a new one but I keep getting the 2 month cap.Hamamelidaceous
Chad, Mine is still working. Not sure why facebook would revoke all your login sessions.Alto
@GeorgeMCeaserJr Have you tried generating a new one recently?Hamamelidaceous
@ChadScira No I have not. Mine is still working and I only have one app page.Alto
Any updates on this? I have one never expiring token but trying to get a token for a different app seems to fail (limited to 3 months).Scolecite
So first remember this only works for FaceBook app pages and app page tokens. I only have one such page currently so I have not been able to try it again. In the next few weeks I will be creating a second page for a new app and will try test it out again there.Alto
I'm also only able to extend a token to 3 months, and no further.Megaron
How to automate this?Teaser
@GeorgeMCeaserJr In your answer, you mentioned a single page, how to do it for multiple pages? Any help really appriciated. Thanks.Forgetful
These steps don't seem to work anymore however I had success by following the instructions on this page medium.com/@blienart/…Barbabas
R
3

Go to your Business settings page, you can get there from your app:

Meta Developers My Apps

Create a new System user with the admin role:

Fb business create system user

Click on add assets and give the system user full control on the page and on your app:

System user assets

Click on generate new token and click on never, make sure of putting the permission you need:

generate token

With that token, use the following URL to generate your page access token without an expiry date:

https://graph.facebook.com/{PAGE-ID}?fields=access_token&access_token={TOKEN}

Meta developers debugger

After a lot of searching, that method worked for me.

Rehm answered 2/10, 2023 at 17:52 Comment(2)
Thank you so much! That solved my problem. I had to add more permissions for my case, but that's all.Masterstroke
You have no idea how many hours you saved me. Thank you so much!Resistive

© 2022 - 2024 — McMap. All rights reserved.