How AI agents connect to Instagram, TikTok and other social networks: OAuth, MCP and official APIs explained
An AI agent connects to a social network through that network's official API: the account owner approves an app on the network's own OAuth consent screen, the app gets an access token limited to the approved permissions, and the agent calls the API with it, renewing the token before it expires. Agents reach those APIs through their own app, a unified API or an MCP server.
easyCoexistence connects your accounts through each network's official API and sign-in, keeps their tokens renewed, and gives Claude, ChatGPT or your own platform one MCP connector and a Partner API for WhatsApp, Instagram, Facebook, TikTok, YouTube, LinkedIn and more channels, with every connection monitored 24/7.
- Each network's own OAuth consent, with no password shared
- Token lifetimes from 1 hour to 60 days, network by network
- Your own app, a unified API or an MCP server, compared
Nothing charged for 3 days. Cancel anytime.
How long a Google user access token, the kind the YouTube APIs take, lasts before it expires.
Lifetime of a TikTok API for Business access token; the refresh token that renews it is valid for one year.
Validity of a long-lived Instagram user token, refreshable for another 60 days once it is at least 24 hours old.
What an MCP server must use for an upstream API: one that API issued, never the token the assistant sent.
What YouTube push notifications report for a channel: a new upload, a new title or a new description.
What does an AI agent need to work on a social account?
Five things, and the network controls each of them. The first is an account the network opens to apps, such as an Instagram professional account, a Facebook Page the person manages or a LinkedIn Page where they hold an admin role, reached through an app the network has approved for the permissions it asks for: Meta grants them one by one through App Review, TikTok reviews each developer app and its scopes, and LinkedIn vets apps before its Standard tier. The second is the owner's consent, given on the network's own sign-in page. The third is an access token, which expires and has to be renewed. The fourth is a permission, or scope, for each job the agent will do. The fifth is webhooks, so the agent hears about a new comment or message as it happens.
None of it involves a password. The agent holds, or borrows from a service, a token that the network can limit, renew or revoke.
How do OAuth sign-in and tokens work on each network?
The same way in outline, with different lifetimes. The app sends the owner to the network's authorization page, the owner logs in there and approves the listed permissions, and the network redirects back with a short-lived code: Instagram's lasts an hour and TikTok's 10 minutes, each usable once, and LinkedIn's 30 minutes. The app's server trades the code for an access token and, on some networks, a refresh token, which mints new access tokens without asking the owner again.
When a refresh fails, or the owner removes the app, calls start failing with an authorization error until the owner signs in again. LinkedIn issues no long-lived tokens and offers programmatic refresh only to a limited set of partners, so without it an app sends the member through authorization again within 60 days.
| Sign-in | Access token | |
|---|---|---|
| Meta's Embedded Signup | A business token scoped to the onboarded business | |
| Instagram Login | 60 days, refreshable for 60 more once a day old | |
| Facebook Login for Business | Long-lived Page tokens have no expiration date | |
| TikTok | TikTok's authorization page | 24 hours, renewed by a refresh token valid for a year |
| YouTube | Google's consent screen | 1 hour, renewed by a refresh token |
| LinkedIn's consent screen | 60 days; refresh tokens for a limited set of partners |
Which permissions does each job need?
One permission for each kind of job, named on the consent screen, and a call goes through only if the token holds the permission behind it. An agent that only reads insights needs far less than one that publishes and replies to comments and DMs, and LinkedIn asks apps to request the fewest scopes they can. Owners choose differently too: Google lets people approve some requested permissions and not others, so an app has to check which ones it received, while LinkedIn presents its scopes as one set that the member accepts or refuses whole. These are the permissions behind the usual jobs:
How does an agent hear about new comments and messages?
Through webhooks, where the network sends them: it posts each event to the app's HTTPS endpoint as it happens, and the endpoint answers 200 at once. Meta sends Instagram comments and DMs, a Facebook Page's feed, messages and mentions, and WhatsApp messages with their delivery statuses, retrying a failed WhatsApp delivery for up to 7 days. TikTok fires comment.update within five minutes of a comment changing and retries for up to 72 hours. YouTube's push notifications report uploads and title or description changes, not comments, and LinkedIn sends a Page's likes, comments and shares only to apps on its Standard tier.
Where no event arrives, the agent reads comments on a schedule instead, and each read counts against the network's rate limits.
What are the three ways to connect an agent: its own app, a unified API or an MCP server?
They differ in who holds the app and the tokens. Building on each network's API with your own app gives full control and the most work: a developer app and its review on each network, an OAuth redirect, token storage and refresh, and webhook endpoints. A unified API is a provider that has done that work once and puts one interface and one key in front of several networks; your code calls it, and it calls the networks. An MCP server packages the same calls as tools that Claude, ChatGPT and other assistants can use, behind an OAuth sign-in of its own.
The MCP specification keeps the two halves apart. The assistant's token is good for the MCP server only, and the server calls each network with a separate token that the network issued, never passing the assistant's token on.
| What you build | Who holds the network tokens | |
|---|---|---|
| Your own app | An app and its review per network, OAuth, token refresh, webhooks | You |
| A unified API | Calls to one API with one key; accounts connect through its hosted sign-in | The provider, which may hand them to your code |
| An MCP server | A connector URL added to the assistant, with OAuth sign-in | The server; the assistant holds only a token for the server |
Where does easyCoexistence fit?
It is both a unified API and an MCP server for AI agents. Accounts connect through easyCoexistence's own app on each network, with the owner signing in on the network's page, so there is no developer app to register and no token to store on your side. Claude, ChatGPT and other MCP clients add one connector, https://easycoexistence.com/api/mcp, with OAuth sign-in and more than 35 tools in all; your own platform uses the Partner API, connects its customers' accounts through hosted links and can take each account's credentials to call the network directly.
easyCoexistence renews tokens before they expire, checks each social connection every 6 hours and forwards Instagram, Facebook and TikTok events to your endpoint, signed per account. What an agent can do still follows each network: it replies to DMs on WhatsApp, Instagram and Messenger, and works in the comments on TikTok, YouTube and LinkedIn. More networks are coming, each joining the same connector and API at the same price per connection.
Common mistakes
- Handing an agent your password. Facebook's terms tell people not to share it, Instagram's forbid collecting other users' login credentials, and a session logged in as you can do anything you can, where a token carries only the permissions you approved.
- Saving a token once and reusing it for months. TikTok's access token lasts 24 hours and an Instagram token lapses after 60 days without a refresh, so renew on schedule or fetch fresh credentials before each job.
- Polling for new comments around the clock. Webhooks push them on the networks that send them, and each poll spends calls from the account's limits, such as TikTok's 40 a minute on each endpoint.
- Asking for scopes the agent will not use. Meta reviews each permission an app requests, and LinkedIn members accept or refuse the whole set at once, so request only what the agent's jobs need.
US$ 9 to US$ 0.75 per connection per month, falling as you add connections, with the first 3 days free.
easyCoexistence is a multichannel API and MCP server that connects AI agents such as Claude and ChatGPT to WhatsApp, Instagram, TikTok, Facebook and more. On WhatsApp it uses Coexistence: the business keeps using its number in the WhatsApp Business app while the AI works through Meta's official API.
Frequently asked questions
Do I need a developer account on each network to connect an AI agent?
Only when you build with your own app. Through a unified API or an MCP server such as easyCoexistence, accounts connect through the provider's app on each network, and the owner only signs in and approves the permissions.
Can Claude and ChatGPT use the same connection to my accounts?
Yes, through one MCP server. Each assistant signs in to it with a token of its own and reaches the same connected accounts, while the network tokens stay with the server.
What happens when a token expires?
Calls fail with an authorization error until the token is renewed. If the refresh token has lapsed too, such as a TikTok one after a year or a Google one left unused for six months, the owner signs in again.
How much does easyCoexistence cost to connect an AI agent to social media?
US$ 9 to US$ 0.75 per connection per month, falling as you add connections, the same on every network. The MCP connector and the Partner API are included, with no seats, and the first 3 days are free.
Keep reading
Connect your first channel in two minutes.
No platform reviews to wait for. Connect WhatsApp, Instagram, TikTok or another channel, then ask your AI to post, reply or report, and watch it work.
- 3 days free
- Cancel any time
- Official APIs only
- Monitored 24/7
Verified on