> This page is for Tools.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.moveworks.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.moveworks.com/_mcp/server.

# How OAuth 2.0 works for HTTP connectors

> Understand how an HTTP connector gets OAuth 2.0 access tokens, choose the right Oauth2 grant type, and see how token requests are sent and cached.

With OAuth 2.0, an HTTP connector doesn't send a long-lived credential on every API call. It first trades something at the provider's token URL, such as a client ID and secret, a refresh token or a signed JWT, for a short-lived access token. It then sends that token with each request as `Authorization: Bearer <access token>`. Select **Oauth2** in the connector's **Auth Config**, then pick a grant in **Oauth2 Grant Type**. If your provider's docs mention a token URL or a `grant_type`, you need OAuth 2.0.

```mermaid
sequenceDiagram
    participant M as Moveworks
    participant T as Token URL
    participant A as API

    M->>T: 1. Request an access token
    T-->>M: 2. access_token
    M->>A: 3. API request with Authorization: Bearer + access token
```

What Moveworks sends in step 1 depends on the grant. See [How the token request is sent](#how-the-token-request-is-sent).

## Choose a grant

With **Auth Config** set to **Oauth2**, **Oauth2 Grant Type** is required. Pick the grant your provider supports for the identity you're connecting with:

![Auth Config set to Oauth2, with the Oauth2 Grant Type dropdown open listing Client Credentials Grant, Password Grant, Refresh Token Grant, Jwt Grant, Authorization Code Grant, Saml Bearer Grant and Jwks Grant.](/_fern-files/_img/3a6a84c45a0176ec350cfe6646cc12494f72cece9d3ef66620f9886d05e138d8.webp)

```mermaid
flowchart TD
    Q1{"Does each employee<br />sign in themselves?"}
    Q1 -- Yes --> AC["Authorization Code"]
    Q1 -- No --> Q2{"Does the token URL take<br />a signed JWT?"}
    Q2 -- Yes --> JG["Jwt Grant or Jwks Grant"]
    Q2 -- No --> Q3{"What do you have<br />for the app?"}
    Q3 -- "Client ID and secret" --> CC["Client Credentials"]
    Q3 -- "A refresh token" --> RT["Refresh Token"]
    Q3 -- "A username and password" --> PW["Password"]
```

| If you…                                                                                                                     | Use                             | Setup                                                                                     |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | ----------------------------------------------------------------------------------------- |
| Have a client ID and secret for an app or service identity. The usual choice for server-to-server calls.                    | **Client Credentials Grant**    | [Client Credentials](/tool-studio/connectors/http-connectors/oauth-20-client-credentials) |
| Need each employee to sign in and grant access with their own permissions.                                                  | **Authorization Code Grant**    | [Authorization Code](/tool-studio/connectors/http-connectors/oauth-20-authorization-code) |
| Have a token URL that accepts a signed JWT assertion (RFC 7523).                                                            | **Jwt Grant** or **Jwks Grant** | [Jwt Grant and Jwks Grant](/tool-studio/connectors/http-connectors/oauth-20-jwt-grant)    |
| Have a long-lived refresh token, and the provider has no client credentials flow for you.                                   | **Refresh Token Grant**         | [Refresh Token](/tool-studio/connectors/http-connectors/oauth-20-refresh-token)           |
| Must send a service account's username and password to get a token. A legacy flow; use it only if the provider requires it. | **Password Grant**              | [Password](/tool-studio/connectors/http-connectors/oauth-20-password-credentials)         |

If the API accepts a credential directly on each request instead, such as an API key or a JWT you sign, you don't need OAuth. See [Choose an auth type](/tool-studio/connectors/http-connectors#choose-an-auth-type).

## How the token request is sent

Moveworks sends a POST to the **Oauth2 Token Url** with an **x-www-form-urlencoded** body, or a JSON body if you add `Content-Type: application/json` under **Oauth2 Custom Oauth Request Options Additional Headers**. **Oauth2 Custom Oauth Request Options Additional Request Data** is added to the body, and **Oauth2 Custom Oauth Request Options Additional Headers** are sent as headers on the token request.

Token endpoints expect the client ID and secret in one of two places: the request body, or a Basic `Authorization` header. For the Client Credentials and Refresh Token grants, Moveworks tries both, so you don't need to choose on the connector:

1. First it sends them in the request body (`client_secret_post`).
2. If that attempt fails for any reason, it retries with them as a Basic `Authorization` header instead (`client_secret_basic`).

For the Password grant, the client ID, client secret, username and password are sent in the request body. The Jwt Grant and Jwks Grant send a signed JWT and no client ID or secret.

## How access tokens are reused

Moveworks caches the access token and fetches a new one before it expires. If the token response has no expiry, the token isn't reused, and a new one is fetched for every request. Jwt Grant and Jwks Grant tokens with a per-user **Subject** template are also fetched for every request. If the API returns `401` for a request, the cached token is cleared and the next request fetches a new one. Authorization Code tokens are kept per employee.