API Reference
Facebook LoginGETLogin dialog
Tokens and permissions

Get an access token

GET/v27.0/oauth/access_token
Base URL: https://meta-ads.mimicr.dev · provider: https://graph.facebook.com

Three grants on one endpoint:

  • Code exchange (client_id, client_secret, redirect_uri, code): returns a 60-day user token. redirect_uri must be identical to the dialog's.
  • Long-lived token (grant_type=fb_exchange_token, fb_exchange_token): returns a new token string with the same user, permissions and assets and a fresh 60-day expiry. The old token stays valid until its own expiry. An expired token can't be exchanged.
  • App token (grant_type=client_credentials): returns {app_id}|{app_secret}.

The same params may be sent with POST in a form body.

In Mimicr, a configuration (config_id) whose token type is system user returns a token without expires_in that never expires. The persona unavailable makes the code exchange fail with a transient error (code 2, HTTP 500).

Authorization

Public route, no token.

Query parameters

client_idstringrequired

The app ID.

client_secretstringrequired

The app secret.

redirect_uristring

Code exchange: the redirect_uri of the dialog.

codestring

Code exchange: the code of the redirect. Valid for 10 minutes, single-use.

grant_typestring

fb_exchange_token or client_credentials. Omit for the code exchange.

fb_exchange_tokenclient_credentials
fb_exchange_tokenstring

The user token to exchange for a long-lived one.

Responses

200Access token.
access_tokenstringrequired

The access token. With client_credentials, the app token {app_id}|{app_secret}.

Example: "EAA…"
token_typestringrequired
bearer
expires_ininteger

Seconds until the token expires: 5183944 (60 days) for user tokens. Absent for app and system user tokens, which don't expire.

Example: 5183944
400101 unknown app, 1 wrong secret, 100 missing code, 100/36007 malformed or expired code, 100/36008 different redirect_uri, 100/36009 code already used, 190 invalid token to exchange.
errorobjectrequired
Show child attributes
messagestringrequired

Description of the error.

Example: "(#100) The parameter special_ad_categories is required"
typestringrequired

OAuthException for most codes (the Marketing API uses it for validation too), GraphMethodException for unknown objects, FacebookApiException for transient errors. In Mimicr, routes outside the integration core answer MimicrNotSimulated with HTTP 501.

Example: "OAuthException"
codeintegerrequired

Error code (100 invalid parameter, 190 invalid token, 200 permission, 2635 deprecated version, 613/17/80004 rate limits, …).

Example: 100
error_subcodeinteger

Error subcode with more detail (1885272 budget too low, 463 token expired, …).

Example: 1885272
is_transientboolean

Whether retrying the same request may succeed. Present on every Marketing API error; true for codes 1 and 2.

error_user_titlestring

Title of the error, to show to people.

error_user_msgstring

Message of the error, to show to people.

error_dataobject

Extra data. blame_field_specs lists the params that caused a validation error.

Show child attributes
blame_field_specsstring[][]
fbtrace_idstringrequired

Internal support identifier of the request.

Example: "AbCdEf12345"
500Transient error: code 2 with is_transient: true. Retry later.
errorobjectrequired
Show child attributes
messagestringrequired

Description of the error.

Example: "(#100) The parameter special_ad_categories is required"
typestringrequired

OAuthException for most codes (the Marketing API uses it for validation too), GraphMethodException for unknown objects, FacebookApiException for transient errors. In Mimicr, routes outside the integration core answer MimicrNotSimulated with HTTP 501.

Example: "OAuthException"
codeintegerrequired

Error code (100 invalid parameter, 190 invalid token, 200 permission, 2635 deprecated version, 613/17/80004 rate limits, …).

Example: 100
error_subcodeinteger

Error subcode with more detail (1885272 budget too low, 463 token expired, …).

Example: 1885272
is_transientboolean

Whether retrying the same request may succeed. Present on every Marketing API error; true for codes 1 and 2.

error_user_titlestring

Title of the error, to show to people.

error_user_msgstring

Message of the error, to show to people.

error_dataobject

Extra data. blame_field_specs lists the params that caused a validation error.

Show child attributes
blame_field_specsstring[][]
fbtrace_idstringrequired

Internal support identifier of the request.

Example: "AbCdEf12345"