How to Get a Permanent Facebook Page Access Token

If you’re building a Python or automation script to post content on your Facebook Page using the Graph API, you might have noticed that your access token expires in just 1 hour by default. This can interrupt automation and require frequent re-authentication.

In this tutorial, I’ll walk you through how to get a long-lived user access token (valid for ~60 days) and then a permanent page access token (with no expiry). All this using Facebook’s official tools:

  • Graph API Explorer
  • Access Token Debugger

Prerequisites

Step-by-Step Guide

Step 1: Open Graph API Explorer

  1. Go to: Graph API Explorer
  2. Select your app from the top-right dropdown.
  3. Click on "Get User Access Token".
  4. Select the following permissions:
    • pages_show_list
    • pages_read_engagement
    • pages_manage_posts
    • (Optional) instagram_basic, instagram_content_publish
  5. Click Generate Access Token.
This token will be short-lived (1 hour) by default.

Step 2: Extend the User Access Token (Optional)

  1. Copy the access token you just generated.
  2. Go to Access Token Debugger
  3. Paste the token and click "Debug".
  4. Click "Extend Access Token" and re-login if asked.
  5. Copy the new long-lived token (~60 days).
Use this token in API calls if you're not automating long-term. But for permanent automation, continue to the next step.

Step 3: Get the Permanent Page Access Token

  1. Go back to Graph API Explorer
  2. Paste your long-lived user token into the Access Token field.
  3. Make a GET request with this query: PAGE_ID?fields=access_token
  4. Replace PAGE_ID with your real Page ID.
{
  "access_token": "EAAGm0PX4ZCpsBAKZC...",
  "id": "YOUR_PAGE_ID"
}
The access_token in this response is your permanent page access token.

Step 4 (Optional): Verify the Page Token

  1. Go to Access Token Debugger
  2. Paste your permanent page token.
  3. Click Debug and verify that "Expires" is Never.

Sample Python Snippet to Use the Token

import requests

PAGE_ACCESS_TOKEN = "EAAGm0PX4ZCpsBAKZC..."
PAGE_ID = "1234567890"

response = requests.post(
    f"https://graph.facebook.com/v18.0/{PAGE_ID}/photos",
    params={
        "url": "https://example.com/image.jpg",
        "caption": "🚀 New post from TheVsHub.in!\nCheck it out 👉 example.com/blog",
        "access_token": PAGE_ACCESS_TOKEN
    }
)

print(response.json())

Final Tips

  • Page tokens work only for the page they’re generated for.
  • If you're using Instagram API, connect the Instagram account to your Facebook Page.
  • Check token expiry using the Access Token Debugger.

Common Issues

Error MessageSolution
(#200) Permissions error Make sure required permissions were selected while generating the token.
Invalid or expired token Use an extended token or repeat the process.
No access_token in response Ensure you're querying with a user token, not an app token.

Useful Links

Wrapping Up

Using this workflow, you can generate a reliable permanent page access token for automation, social media publishing, or AI-based tools.

Need help building an Instagram + Facebook Auto Poster using Python? Follow my tutorials on TheVsHub.in.

Tags:Facebook API, Graph API, Python Automation, Access Token, Facebook Page Token, Instagram API, Social Media Automation, Developer Guide, TheVsHub

Vishvesh Shivam

Vishvesh Shivam is the dynamic founder of TheVsHub.in, a platform he is continually refining with his passion and dedication. A web developer and student based in the scenic Himachal Pradesh, Vishvesh embodies self-reliance and innovation. His quick decision-making ability and relentless drive set him apart, fueling his mission to elevate TheVsHub.in every single day.

Post a Comment

We Love Hearing from You!
Thank you for reading our post! Your thoughts and opinions are important to us. Please leave a comment below to share your feedback, ask questions, or start a discussion. We look forward to engaging with you!

Note: Comments are moderated to ensure a respectful and positive environment.

Previous Post Next Post
Code Copied!