Get a connector's access token for its provider
Ask Marfa for a short-lived access token for the provider a plugin's connector signed in to, and act on each refusal.
A plugin's connector that declares sign_in calls its provider, such as Google, with an access token that Marfa makes. The owner signs in once in a browser, and Marfa stores the refresh token as one of the connector's secret settings. A connector that asks Marfa for its access token needs no refresh token and no client secret. Connectors are in alpha: what alpha means.
Ask for a token
Ask with the key the connector registered under, which is the key its host minted. The ID is the registration's.
POST /connectors/01a1fa31-0d2e-7c4a-9b51-3f2c8e6d1a07/access-token
Authorization: Bearer $MARFA_API_KEYHTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "ya29.a0AfH6SMBexample",
"expires_at": "2026-11-22T10:30:00.000Z",
"scopes": ["https://www.googleapis.com/auth/calendar.events"]
}expires_atis at least five minutes ahead.scopesholds the scopes the provider reported. It is an empty list when the provider reported none.
Marfa answers the token it holds while that token has more than five minutes left, and asks the provider only when it needs another. Requests for one plugin's connector that arrive together share one refresh. Marfa holds an access token in memory only.
Act on a refusal
| Answer | What it means | What to do |
|---|---|---|
409 connector_ | Marfa holds no refresh token it can read. | Wait for the owner to sign in. |
409 connector_ | The client ID or the client secret has no value Marfa can read. details.settings names each. | Wait for the owner to set them. |
409 connector_ | The provider refused the stored sign-in. details.reason is invalid_grant, invalid_client or unauthorized_client. | Stop asking. Only a new sign-in by the owner mends it. |
503 connector_ | The provider did not answer in time, or gave no usable token. details.reason is an outcome word, such as timeout. | Ask again after Retry-After. |
409 connector_ | The plugin's connector declares no sign_in. | Declare it in the plugin. |
403 forbidden | The caller is not the key the connector registered under. | Use the connector's own key. |
No other credential gets the token: not the owner, an app, another connector's key or a key that holds connectors.manage. A connector host's own key is answered 401 unauthorized.
After connector_sign_in_required, Marfa answers the same refusal without asking the provider, until a new sign-in finishes. After connector_sign_in_unavailable, it does the same until the wait in Retry-After has passed.
What the owner sees
A sign-in the provider refused shows in two places.
- The sign-in's status answers
refused_reason, the provider's word, andrefused_at, the time of the refusal. Both arenullwhile the provider has refused nothing. - The attention list, which
marfa attentionprints, holds one entry of kindsetting. Itsreferenceis the plugin's name followed by/connector/sign-in, such asgoogle-calendar/connector/sign-in.
A new sign-in that finishes clears both, and the next request asks the provider again. A 503 connector_sign_in_unavailable marks nothing: the sign-in still stands.
What Marfa sends the provider
Marfa sends a provider's address two requests and no other (plugins/sign-in-only-request):
- The token request that finishes a sign-in the owner started.
- The refresh, only when the connector's own key asks for an access token.
A refresh that gives a token leaves a connector.token_refreshed entry in the audit log, and a refusal by the provider leaves connector.token_refresh_failed. Neither holds a token.
The rules are in the connectors chapter of the contract, under A plugin connector's access token.