> ## Documentation Index
> Fetch the complete documentation index at: https://docs.junction.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Link Errors

> Handle errors from Junction Link including OAuth flow query parameter errors and JSON response errors for password and email providers.

## Error delivery

### URL Query

Junction performs a 307 Temporary Redirect to the `redirect_url` specified in your Link Token in the following scenarios:

* All connections via [the Junction Link widget](/wearables/connecting-providers/introduction)
* [Connect OAuth Provider](/api-reference/link/link-oauth-provider) endpoint used by your [Custom Widget](/wearables/connecting-providers/custom_widget)

Error parameters would be appended to the `redirect_url` before the redirection. For example,
given a redirect\_url of `https://example.com/vital/callback`:

```
https://example.com/vital/callback
?state=error
&error_type=provider_credential_error
&error=Invalid%20username%20or%20password
```

### JSON Response

Junction responds 200 OK with a JSON response in the following scenarios:

* [Connect Password Provider](/api-reference/link/link-password-provider) endpoint used by your [Custom Widget](/wearables/connecting-providers/custom_widget)
* [Connect Email Provider](/api-reference/link/link-email-provider) endpoint used by your [Custom Widget](/wearables/connecting-providers/custom_widget)

Error parameters would be embedded into the JSON response. For example:

```json theme={null}
{
  "state": "error",
  "error_type": "provider_credential_error",
  "error": "Invalid username or password"
}
```

## Error Parameters

<ResponseField name="state" type="const string">
  Constant: `error`
</ResponseField>

<ResponseField name="error_type" type="string">
  One of the [Link Error Types](#error-types).
</ResponseField>

<ResponseField name="error" type="string">
  A human-readable error explanation for troubleshooting purposes.
  Your application logic should not rely on this message.
</ResponseField>

## Error Types

<Note>
  This list is **non-exhaustive**. Your application logic must gracefully handle any unrecognized error type.
</Note>

| Error Type                    | Description                                                                                                                                                                                                                                                             |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `invalid_token`               | The Link Token is invalid or malformed.                                                                                                                                                                                                                                 |
| `token_expired`               | The Link Token has expired.                                                                                                                                                                                                                                             |
| `token_consumed`              | A successful connection establishment has consumed this Link Token.                                                                                                                                                                                                     |
| `provider_credential_error`   | <ul><li>OAuth: An error occurred during the provider authentication flow.</li><li>Password & Email: The supplied user credential is invalid.</li></ul>                                                                                                                  |
| `provider_password_expired`   | The supplied password has expired due to the password rotation policy of the provider. The user must rotate their password directly with the provider before trying to connect again. <Info>Applicable only to the patient-based `abbott_libreview` integration.</Info> |
| `provider_api_error`          | An unexpected error occurred when Junction Link attempts to connect to the provider API.                                                                                                                                                                                |
| `unsupported_region`          | The region you specified is not supported. <Info>Applicable only to the practice-based `freestyle_libre` integration.</Info>                                                                                                                                            |
| `duplicate_connection`        | The provider credential has an existing connection to a different user in your team. <Info>Applicable only if you have opted in to the `reject_duplicate_connection` team setting.</Info>                                                                               |
| `required_scopes_not_granted` | User did not grant **all** required scopes, so Junction cannot establish the connection.                                                                                                                                                                                |
| `incorrect_mfa_code`          | The MFA code entered is incorrect.                                                                                                                                                                                                                                      |
