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.
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
| Token | Represents | Typical lifetime | Use it for |
|---|---|---|---|
| User (short lived) | A person | About one to two hours | The moment right after login |
| User (long lived) | A person | About 60 days | Background work tied to one person |
| Page | A Page | Inherits the user token | Posting, moderation, Page insights |
| App | Your app itself | Until you reset the secret | App settings, token inspection |
| System user | A business automation identity | No expiry time | Scheduled 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.
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
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.
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.
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.
| Code | Meaning | Correct response |
|---|---|---|
| 190 subcode 458 | App not installed | Send the user back through login |
| 190 subcode 459 | User checkpointed | Ask them to resolve it on Facebook |
| 190 subcode 460 | Password changed | Require a fresh login |
| 190 subcode 463 | Token expired | Reauthenticate, do not retry |
| 190 subcode 467 | Token invalid or revoked | Clear stored token, reauthenticate |
| 4 or 17 | Throttling | Back 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
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.

