Facebook + Google Sheets: tokens stay valid
Your Facebook automations don’t usually “break.” They just quietly stop working because a Page Access Token expired, and you find out after a post fails or leads stop syncing.
This Facebook token renewal automation hits marketing managers first, but agency owners and ops folks maintaining client pages feel the pain too. Instead of chasing down credentials every few weeks, you keep a single, current token available when your workflows need it.
This n8n workflow renews long-lived Page tokens on a schedule and stores the latest values so you’re not firefighting. Below you’ll see how it runs, what it saves you, and what you need to plug it into your setup.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Facebook + Google Sheets: tokens stay valid
flowchart LR
subgraph sg0["Schedule Flow"]
direction LR
n0@{ icon: "mdi:swap-vertical", form: "rounded", label: "Set Parameter", pos: "b", h: 48 }
n1@{ icon: "mdi:swap-vertical", form: "rounded", label: "Split Out", pos: "b", h: 48 }
n2@{ icon: "mdi:swap-vertical", form: "rounded", label: "Edit Fields", pos: "b", h: 48 }
n3@{ icon: "mdi:cog", form: "rounded", label: "Upsert row(s)", pos: "b", h: 48 }
n4@{ icon: "mdi:play-circle", form: "rounded", label: "Schedule Trigger", pos: "b", h: 48 }
n5["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Get long lived facebook user.."]
n6["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Get list facebook page"]
n7["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>Get long lived facebook page.."]
n1 --> n2
n2 --> n3
n0 --> n5
n4 --> n0
n6 --> n7
n7 --> n1
n5 --> n6
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n4 trigger
class n5,n6,n7 api
classDef customIcon fill:none,stroke:none
class n5,n6,n7 customIcon
The Problem: Expired Facebook tokens break your automations
Facebook Page Access Tokens have a habit of expiring at the worst possible time. One day your lead sync is fine. The next day, nothing updates, your reporting is missing rows, and someone asks why the campaign “stopped.” Then you’re digging through Facebook Developer Tools, trying to remember which app owns the token, which user generated it, and where you pasted it last time. Meanwhile, the business cost keeps ticking: missed leads, delayed replies, and hours spent on credential cleanup instead of actual marketing work.
It adds up fast. Here’s where it usually breaks down.
- You only notice token expiry after a post, ad workflow, or lead sync fails silently.
- Tokens live in too many places (a doc, a teammate’s notes, an old workflow), so you update one and forget the others.
- Manual renewal pulls you into Facebook Developer Tools, which is rarely quick when you’re in a hurry.
- When you manage multiple pages, renewing page-by-page becomes a recurring maintenance task that never really ends.
The Solution: Renew Page tokens on schedule and store the latest value
This workflow tackles token expiry the boring way, which is honestly the best way. It runs on a schedule (every two months by default), exchanges your short-lived Facebook user token for a long-lived user token, then uses that long-lived token to pull the list of Facebook Pages you manage. For each page, it requests the current Page Access Token, extracts the fields you care about (token, page name, page ID), and stores them in a table so your other automations always have a “latest token” to grab. No Slack panic. No “why did this stop?” detective work.
The workflow starts with a Scheduled Trigger. Next, HTTP requests handle the token exchange and page-token retrieval. Finally, n8n maps the fields and upserts each page’s record into storage (which you can point to a Data Table or Google Sheets).
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you manage 6 Facebook Pages and you have 3 workflows that depend on a valid Page token (lead capture, posting, and reporting). When a token expires, you typically spend about 15 minutes finding the right app/user, regenerating the right values, then updating tokens in each workflow, which is roughly 1–2 hours per “incident.” With this automation, you spend maybe 20 minutes one time to set credentials in n8n, and the workflow refreshes tokens every two months automatically. After that, your other automations just read the newest token from one place.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Facebook Developer App to generate client ID and secret.
- Google Sheets to store tokens in a shared sheet.
- Facebook credentials (client_id, client_secret, user_access_token, app_scoped_user_id from Facebook Developer Tools)
Skill level: Intermediate. You’ll paste credentials, test API calls, and confirm the sheet/table columns match.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A scheduled run kicks things off. The workflow uses an n8n Schedule Trigger set to every two months, so token refresh happens before expiry becomes a problem.
Credentials are loaded once, consistently. In a single “Assign Auth Variables” step, you set your Facebook app credentials and the starting user token, which keeps everything centralized and easier to maintain.
Facebook token exchange happens via HTTP requests. n8n calls Facebook’s endpoints to swap the short-lived user token for a long-lived user token, then pulls the list of Pages you manage and requests a Page token for each one.
Tokens are formatted and stored where your team can access them. The workflow splits the page list into individual records, maps the token/name/id fields, and upserts them so your “latest token” is always available (in an n8n Data Table by default, or Google Sheets if you prefer).
You can easily modify the schedule and where tokens are stored based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Schedule Trigger
This workflow starts on a scheduled interval and then refreshes Facebook Page tokens.
- Add or open Scheduled Run Initiator.
- Set the schedule rule to run every
2months (the node uses a months interval of2). - Connect Scheduled Run Initiator to Assign Auth Variables.
Step 2: Connect Facebook Auth Inputs
These variables are used by the HTTP requests to obtain and refresh long-lived tokens.
- Open Assign Auth Variables and set the following fields:
- Set client_id to
[YOUR_ID]. - Set client_secret to
[CONFIGURE_YOUR_API_KEY]. - Set user_access_token to
[CONFIGURE_YOUR_TOKEN]. - Set app_scoped_user_id to
[YOUR_ID]. - Keep long_user_access_token mapped to
{{ $json.body.access_token }}. - Connect Assign Auth Variables to Fetch Long User Token.
Step 3: Set Up Token Retrieval Requests
These HTTP requests exchange the user token for a long-lived token and then fetch the page list.
- Open Fetch Long User Token and set URL to
https://graph.facebook.com/v23.0/oauth/access_token. - Enable Send Query and configure query parameters:
- grant_type =
fb_exchange_token - client_id =
{{ $json[' client_id'] }} - client_secret =
{{ $json[' client_secret'] }} - fb_exchange_token =
{{ $json.user_access_token }} - Open Retrieve Page Catalog and set URL to
https://graph.facebook.com/v23.0/me/accounts. - Set the query parameter access_token to
{{ $json.body.access_token }}. - Confirm the flow Fetch Long User Token → Retrieve Page Catalog.
Step 4: Request and Map Page Tokens
This section requests page tokens, splits the list, and maps the values for storage.
- Open Request Page Token and set URL to
=https://graph.facebook.com/v23.0/{{ $('Assign Auth Variables').item.json.app_scoped_user_id }}/accounts. - Set Method to
=GETand enable Send Query. - Set query parameter access_token to
{{ $('Fetch Long User Token').item.json.body.access_token }}. - Connect Retrieve Page Catalog → Request Page Token → Expand Records.
- In Expand Records, set Field to Split Out to
body.dataand Include toallOtherFields. - Open Map Token Fields and map:
- access_token =
{{ $json['body.data'].access_token }} - name =
{{ $json['body.data'].name }} - id =
{{ $json['body.data'].id }}
Step 5: Configure the Output Table Upsert
Store the refreshed tokens in your data table with an upsert operation.
- Open Upsert Table Records and set Operation to
upsertwith Match Type set toallConditions. - Select your target data table in Data Table ID (replace
[YOUR_ID]). - Map columns:
- token =
{{ $json.access_token }} - id_page =
{{ $json.id }} - name_page =
{{ $json.name }} - Set the filter condition id_page to
{{ $json.id }}to ensure upsert matching. - Confirm the flow Map Token Fields → Upsert Table Records.
Step 6: Test & Activate Your Workflow
Validate the end-to-end flow before enabling scheduled runs.
- Click Execute Workflow to run it manually.
- Verify Fetch Long User Token returns a
body.access_tokenand Request Page Token returns a list inbody.data. - Confirm Upsert Table Records writes or updates rows in your data table with token, id_page, and name_page.
- Once successful, switch the workflow to Active to enable scheduled execution.
Common Gotchas
- Facebook Developer credentials can expire or lack permissions. If things break, check your app settings and token status in Facebook Developer Tools first.
- If you add Wait nodes or Facebook’s API responds slowly, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Google Sheets writes can fail when the sheet headers change. If you rename columns, update the mapping so token, page name, and page ID still land in the right places.
Frequently Asked Questions
About 30 minutes if you already have your Facebook app credentials.
No. You’ll paste credentials, connect accounts, and test one run in n8n.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in Facebook API usage (usually minimal for token refresh calls).
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, but you’ll want to add the filter in the right spot. After the workflow expands the list of Pages into individual records, insert a filter step that keeps only matching page IDs or page names. Then let the mapping and upsert continue as-is, so only the Pages you care about land in your table or Google Sheet.
Usually it’s expired or invalid credentials in the “Assign Auth Variables” values, especially the short-lived user_access_token you start with. Regenerate that token in Facebook Developer Tools, then rerun the workflow to confirm it can exchange it for a long-lived user token. Another common issue is missing permissions on the Facebook app (or the user who created the token), which prevents Page token retrieval for some pages. If it fails only for one client page, check whether you actually have admin rights for that Page under the same user.
For most small teams, dozens of Pages is fine because the workflow is just a few API calls per page on a schedule.
Often, yes, because token refresh flows tend to need multi-step HTTP calls, data mapping, and a reliable place to store the latest value. n8n handles that kind of logic cleanly, and self-hosting means you’re not paying per tiny step. Zapier or Make can work, but you’ll usually spend more time fighting the “one more web request” problem and step limits. If your setup is simple and you already live in those tools, they’re fine. If you’re unsure, Talk to an automation expert and you’ll get a straight recommendation.
Once this is running, token renewal becomes background noise. Your Facebook workflows keep moving, and you get your time back for the work that actually grows the account.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.