Skip to navigation

How OAuth 2.0 works for HTTP connectors

View as Markdown

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.

1. Request an access token 2. access_token 3. API request with Authorization: Bearer + access token Moveworks Token URL API

What Moveworks sends in step 1 depends on the grant. See 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.

Yes No Yes No Client ID and secret A refresh token A username and password Does each employeesign in themselves? Authorization Code Does the token URL takea signed JWT? Jwt Grant or Jwks Grant What do you havefor the app? Client Credentials Refresh Token Password
If you…UseSetup
Have a client ID and secret for an app or service identity. The usual choice for server-to-server calls.Client Credentials GrantClient Credentials
Need each employee to sign in and grant access with their own permissions.Authorization Code GrantAuthorization Code
Have a token URL that accepts a signed JWT assertion (RFC 7523).Jwt Grant or Jwks GrantJwt Grant and Jwks Grant
Have a long-lived refresh token, and the provider has no client credentials flow for you.Refresh Token GrantRefresh 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 GrantPassword

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.

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.