Close Menu
GeekBlog

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Quantum Immortality Is Going Viral as “the Most Horrifying Idea Ever.” Here’s Why Physicists Aren’t Losing Sleep.

    November 18, 2026

    Huawei Watch Air Leaks at 6.9mm: A Titanium Smartwatch Thinner Than a Fitness Band, With a 5-Day Battery

    November 18, 2026

    Grindr’s $120-a-Month Edge Tier Uses AI to Guess Who Will Reply. Its CEO Says Not Everyone Should Buy It.

    November 18, 2026
    Facebook
    GeekBlog
    • Home
    • Mobile
    • Tech News
    • Blog
    • Gaming
    • Smartwatch
    • How-To Guides
    • AI & Software
    Facebook
    GeekBlog
    Home»Blog»Facebook API Authentication and Access Tokens Explained
    Blog

    Facebook API Authentication and Access Tokens Explained

    Ethan CaldwellBy Ethan CaldwellSeptember 4, 20269 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    Developer pointing at code on a laptop screen
    Photo via Pexels
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link

    Facebook API authentication comes down to picking the right token for the job and then keeping it alive. There are five token types, they have different lifetimes and different trust levels, and choosing wrongly is the reason most integrations break within a few weeks of going live. Everything below is written against Graph API v26.0, which Meta released on July 29, 2026.

    Quick answer: Use a user access token for actions a person triggers, a Page access token for anything that acts as a Page, an app access token for server to server settings calls, and a system user token for scheduled automation because it does not expire. Exchange a short lived user token for a long lived one at GET /v26.0/oauth/access_token?grant_type=fb_exchange_token, send appsecret_proof on every server call, and inspect any token with GET /v26.0/debug_token?input_token=<TOKEN>.

    The mental model that helps: a token is a bundle of three facts, namely who it represents, which app issued it, and which permissions the person granted. Every authorization failure you will ever debug is one of those three being wrong. The token types below differ mostly in the first fact.

    The five token types and when to use each

    TokenRepresentsTypical lifetimeUse it for
    User (short lived)A personAbout one to two hoursThe moment right after login
    User (long lived)A personAbout 60 daysBackground work tied to one person
    PageA PageInherits the user tokenPosting, moderation, Page insights
    AppYour app itselfUntil you reset the secretApp settings, token inspection
    System userA business automation identityNo expiry timeScheduled jobs, ad automation

    There is also a client token, a low privilege value used by native and desktop clients to reach app level APIs. Since SDK version 13 the mobile SDKs require it for Graph API calls, which is covered alongside the rest of the mobile setup in our guide to using the Facebook SDKs in mobile app development.

    Page tokens are the ones most integrations actually need, because almost anything that publishes or reads Page content requires acting as the Page rather than as the person. The practical shape of that is shown in our guide to posting content to a Facebook timeline.

    Warning: An app access token is your app secret in another shape. Never embed one in a mobile binary, a browser bundle or a public repository. Anyone holding it can change your app settings.

    Exchanging a short lived token for a long lived one

    Web login hands your client a token that dies in an hour or two. Post it to your backend and exchange it there, because the call requires your app secret.

    curl -G "https://graph.facebook.com/v26.0/oauth/access_token" \
      -d "grant_type=fb_exchange_token" \
      -d "client_id=<YOUR_APP_ID>" \
      -d "client_secret=<YOUR_APP_SECRET>" \
      -d "fb_exchange_token=<SHORT_LIVED_USER_TOKEN>"

    The response carries an access_token valid for roughly 60 days. To get Page tokens, call the accounts edge with that long lived user token. Page tokens obtained this way inherit the long lifetime, which is the whole point of doing the exchange first.

    curl -G "https://graph.facebook.com/v26.0/me/accounts" \
      -d "access_token=<LONG_LIVED_USER_TOKEN>"
    
    # response contains one entry per Page the user administers:
    # { "data": [ { "id": "<PAGE_ID>", "name": "...",
    #               "access_token": "<PAGE_TOKEN>", "tasks": [...] } ] }

    Signing calls with appsecret_proof

    Recommended for you:

    How to Use User Generated Content in Your Marketing
    Blog·Sep 4, 2026

    How to Use User Generated Content in Your Marketing

    Meta lets you require that every server call carries a proof that you hold the app secret. Turn it on in the App Dashboard under Settings, then Advanced, in the Security block, using the Require App Secret toggle. The proof is a SHA256 HMAC of the access token concatenated with a timestamp, keyed with the app secret, expressed in hexadecimal.

    import hashlib, hmac, time, requests
    
    APP_SECRET = "<YOUR_APP_SECRET>"
    TOKEN = "<YOUR_ACCESS_TOKEN>"
    
    def signed_params(token: str) -> dict:
        ts = int(time.time())
        proof = hmac.new(
            APP_SECRET.encode("utf-8"),
            f"{token}|{ts}".encode("utf-8"),
            hashlib.sha256,
        ).hexdigest()
        return {"access_token": token, "appsecret_proof": proof, "appsecret_time": ts}
    
    r = requests.get(
        "https://graph.facebook.com/v26.0/me",
        params={"fields": "id,name", **signed_params(TOKEN)},
        timeout=10,
    )
    print(r.json())

    Two details matter. The timestamp must be an integer before you hash it, and you must send that same value as appsecret_time alongside the proof. Meta treats a proof as stale after five minutes, so generate a fresh one per request rather than caching it.

    Tip: Because the proof needs your app secret, turning the requirement on forces every call through your own backend. That is a feature. It also means a leaked user token alone is not enough for an attacker to impersonate your app.

    Inspecting a token before you trust it

    Any token your client sends you is a claim, not a fact. Verify it with the debug_token endpoint using an app access token or a developer’s own user token.

    curl -G "https://graph.facebook.com/v26.0/debug_token" \
      -d "input_token=<TOKEN_TO_INSPECT>" \
      -d "access_token=<YOUR_APP_ID>|<YOUR_APP_SECRET>"

    The response returns app_id, is_valid, user_id, scopes, granular_scopes, issued_at, expires_at and data_access_expires_at. Check three things every time: that is_valid is true, that app_id matches your own app, and that the scopes actually include what your next call needs. Skipping the app ID check is a classic hole, because a token minted for a different app will otherwise look perfectly healthy.

    The Access Token Debugger in the developer tools section does the same inspection in a browser and is the fastest way to answer why did this token stop working during a support call.

    Note: expires_at and data_access_expires_at are different clocks. The first is when the token stops authenticating. The second is when Meta cuts off access to that person’s data because they have not used your app recently, and it can arrive first.

    Permissions, scopes and App Review

    Only public_profile is granted automatically. Everything else has to be requested at login and then approved through App Review before it works for anyone who does not hold a role on your app. That two stage model is why an integration works perfectly for the developer and fails for the first real customer.

    Standard Access covers testing and assets your own business owns. Advanced Access covers the general public and, for the ads permissions, requires business verification of the legal entity behind the app. Request the narrowest scope set that does the job, because every extra permission adds a review surface and a reason for a user to decline. If you are heading toward ad automation, the tiers and review steps are laid out in our guide to creating and managing Facebook ads through the API.

    Users can also grant a subset of what you asked for. Read the granted list back from /me/permissions after login and design the product so a declined scope degrades a feature rather than breaking the session.

    Handling expiry and revocation

    Tokens die for reasons that have nothing to do with your code: a password change, a revoked app, a security checkpoint, or simple inactivity. Meta signals all of this with an OAuthException carrying code 190 and a subcode that tells you what to do next.

    CodeMeaningCorrect response
    190 subcode 458App not installedSend the user back through login
    190 subcode 459User checkpointedAsk them to resolve it on Facebook
    190 subcode 460Password changedRequire a fresh login
    190 subcode 463Token expiredReauthenticate, do not retry
    190 subcode 467Token invalid or revokedClear stored token, reauthenticate
    4 or 17ThrottlingBack off and retry later

    Build the distinction into your client: throttling errors are retryable, authentication errors are not. Retrying a 190 in a loop just generates noise and can look like abuse. Store the expiry alongside the token, refresh long lived user tokens well before day 60 while the user is active, and mark the connection as needing reauthorization the moment a 190 arrives so the interface can prompt instead of silently failing.

    Troubleshooting

    Every call returns error 190 immediately after login. You are probably sending a Page token where a user token is expected, or vice versa. Run the token through debug_token and look at whether profile_id is populated.

    Calls fail only from production. The Require App Secret toggle is on and your production path is not attaching appsecret_proof. It works locally because the toggle was flipped after your development environment was built.

    The proof is rejected as invalid. The timestamp used in the hash does not match the one sent as appsecret_time, or the server clock has drifted past the five minute window. Sync the clock and generate both values in the same function.

    A permission shows in the dialog but not in the token. The user declined that specific item. Read /me/permissions and handle a partial grant rather than assuming the login succeeded in full.

    A long running job dies exactly 60 days after launch. It is running on a long lived user token. Move it to a system user token, which has no expiry time, and stop tying automation to a specific employee’s account.

    Frequently asked questions

    Recommended for you:

    How to Create a Namespace in Minikube (2026)
    Blog·Sep 4, 2026

    How to Create a Namespace in Minikube (2026)

    Do long lived Page tokens really never expire?

    They persist as long as the underlying user token stays valid and the person keeps their Page role. They still die when the user changes their password, revokes the app, or loses admin rights. For automation that must survive staff changes, use a system user token instead.

    Can I refresh a long lived token before it expires?

    You can run the fb_exchange_token exchange again with a valid long lived token to get one with a fresh window, provided the user has been active in your app. There is no separate refresh token in the OAuth sense, so plan for a reauthorization path.

    What is the difference between scopes and granular_scopes?

    The scopes array lists the permissions granted. The granular_scopes array narrows each one to specific target IDs, such as the exact Pages or ad accounts covered. Check granular scopes when a permission looks present but a call against one particular asset still fails.

    Is appsecret_proof mandatory?

    Not by default, but it becomes mandatory once you enable Require App Secret in the App Dashboard, and enabling it is good practice for any server side integration. It costs a few lines of code and removes a whole class of stolen token attacks.

    How should I store tokens?

    Encrypted at rest, scoped to the account they belong to, and never in a log line or an error report. Store the expiry timestamp beside the token so a background job can refresh or flag the connection without calling Meta just to find out.

    The bottom line

    Pick the token that matches the actor, not the one that was easiest to get. People get user tokens, Pages get Page tokens, and anything running on a schedule gets a system user token so it stops depending on a human account that will eventually change a password.

    After that, three habits cover most of the pain: exchange short lived tokens on your server, sign every call with appsecret_proof, and inspect incoming tokens with debug_token before you trust them. Meta’s debug_token reference lists every field the inspection returns, and it is worth reading once in full.

    About this article: GeekBlog covers U.S. technology news, AI, phones, smartwatches and gaming. Every story is written and checked under our Editorial Policy. Spotted a mistake or have a story tip? Contact our editors.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Telegram Email Copy Link
    Previous ArticleHow to Use User Generated Content in Your Marketing
    Next Article Is Georgia a Good State to Invest in Real Estate?
    Ethan Caldwell

      Ethan Caldwell is GeekBlog's resident Apple specialist, covering the entire Apple ecosystem: iPhone, iPad, Mac, Apple Watch, AirPods and the software that ties them together. A longtime iOS user and gadget collector, Ethan tracks Cupertino's every move, breaking down Apple keynotes, A- and M-series chip benchmarks, iOS feature updates and the rumor mill into clear, practical takes that help readers decide whether the latest Apple hardware is worth the upgrade.

      Related Posts

      10 Mins Read

      Google Ads Keyword Planner: How It Shows the Most Relevant Keywords

      11 Mins Read

      How to Use Remarketing Techniques for Better Conversions

      11 Mins Read

      How to Conduct A/B Testing for Marketing Campaigns

      10 Mins Read

      AMP for WP Plugin Vulnerability: What Was Fixed and What to Do

      11 Mins Read

      How to Create a Facebook Business Page in 2026

      11 Mins Read

      How to Convert GMT Time to Other Time Zones in C++

      Top Posts

      Every iPhone Camera Ranked in 2026 (Best to Worst)

      July 6, 2026338 Views

      Best Browser for Android in 2026: Top Picks Ranked

      July 7, 2026201 Views

      iPhone Battery Replacement Cost: Every Model, Apple vs Repair Shop

      October 6, 2026168 Views
      Stay In Touch
      • Facebook

      Subscribe to Updates

      Get the latest tech news from FooBar about tech, design and biz.

      Most Popular

      Apple Told Its Stores Not to Expect iPhone Duo Walk-Ins. Carriers Can Beat January by Weeks.

      October 20, 2026286 Views

      Apple Watch Black Friday 2026: Early Deals, Prices to Beat and When to Buy

      November 8, 2026268 Views

      One UI 9 Watch: Which Galaxy Watches Get Wear OS 7, and Who Gets Left Behind

      November 6, 2026170 Views
      Our Picks

      Quantum Immortality Is Going Viral as “the Most Horrifying Idea Ever.” Here’s Why Physicists Aren’t Losing Sleep.

      November 18, 2026

      Huawei Watch Air Leaks at 6.9mm: A Titanium Smartwatch Thinner Than a Fitness Band, With a 5-Day Battery

      November 18, 2026

      Grindr’s $120-a-Month Edge Tier Uses AI to Guess Who Will Reply. Its CEO Says Not Everyone Should Buy It.

      November 18, 2026

      Subscribe to Updates

      Get the latest creative news from FooBar about art, design and business.

      HEICJPG.online - Convert HEIC to JPG online
      Facebook
      • About GeekBlog: Our Mission, Team and Editorial Standards
      • Contact us
      • Privacy Policy
      • Disclaimer
      • Terms and Conditions
      • Editorial Policy
      • Cookie Policy
      • Your Privacy Choices
      © 2026 GeekBlog

      Type above and press Enter to search. Press Esc to cancel.