# Get a connector's access token for its provider (/build/connector-sign-in)

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`](/reference/plugin-format#connector) calls its provider, such as Google, with an access token that Marfa makes. The owner [signs in once in a browser](/use/connector-google-access), 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](/catalog/connectors#what-alpha-means).

## Ask for a token [#ask-for-a-token]

[Ask](/reference/api/connector-state/getConnectorAccessToken) with the key the connector registered under, which is the key its host minted. The ID is the registration's.

```http title="Request"
POST /connectors/01a1fa31-0d2e-7c4a-9b51-3f2c8e6d1a07/access-token
Authorization: Bearer $MARFA_API_KEY
```

```http title="Response"
HTTP/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_at` is at least five minutes ahead.**
* **`scopes` holds 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 [#act-on-a-refusal]

| Answer | What it means | What to do |
| - | - | - |
| `409 connector_not_signed_in` | Marfa holds no refresh token it can read. | Wait for the owner to sign in. |
| `409 connector_sign_in_settings_missing` | 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_sign_in_required` | 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_sign_in_unavailable` | 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_sign_in_not_declared` | 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 [#what-the-owner-sees]

**A sign-in the provider refused shows in two places.**

* [The sign-in's status](/reference/api/plugins/getPluginConnectorSignIn) answers `refused_reason`, the provider's word, and `refused_at`, the time of the refusal. Both are `null` while the provider has refused nothing.
* [The attention list](/reference/api/health-and-maintenance/listAttention), which `marfa attention` prints, holds one entry of kind `setting`. Its `reference` is the plugin's name followed by `/connector/sign-in`, such as `google-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 [#what-marfa-sends-the-provider]

Marfa sends a provider's address two requests and no other ([`plugins/sign-in-only-request`](https://github.com/withmarfa/marfa/blob/main/conformance/spec/plugins.md#pluginssign-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](/use/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](https://github.com/withmarfa/marfa/blob/main/conformance/spec/connectors.md#a-plugin-connectors-access-token).
