Skip to main content

OAuth 2.0

OAuth 2.0 connections obtain access tokens from a provider, store them encrypted, refresh them before they expire, and add them to every request made with the connection.

Platform OAuth or your own OAuth app​

There are two ways to get an OAuth connection:

Platform OAuth app (one click)Your own OAuth app
WhereOfficial apps with an OAuth option, such as Sign in with GitHub, Add to Slack, Sign in with Notion or Sign in with GoogleApps → Generic → Any REST API → OAuth 2.0, Google Sheets Bring your own OAuth app, or a custom app with the OAuth 2.0 auth strategy
Client ID and secretBlokkio's. You never see them.Yours, from the provider's developer console
Redirect URIAlready registered by BlokkioYou register it with the provider (see below)
ScopesFixed by the appYou choose
SetupClick Sign in and approveCreate the OAuth app, fill in the fields, then sign in

Use the platform OAuth app whenever the app offers it: the option shows (one click) in the catalogue. It is only offered for apps where Blokkio has registered its own OAuth app. Use your own OAuth app for services without an official app, when you need other scopes, or when your organization requires its own OAuth client.

Register your OAuth app with the provider​

This section is only for your own OAuth app. For the authorization code grant, create an OAuth app in the provider's developer console and register this redirect URI (also called callback URL):

https://api.blokkio.com/api/connections/oauth2/callback

The provider sends the user back to this URL after they grant access. Blokkio's API exchanges the code for tokens on the server and then returns you to the app. Copy the client ID and client secret from the provider.

Blokkio always sends its own redirect URI. A Redirect URI field in the connection form, if present, is ignored.

Grant types​

Grant typegrant_type valueWhen to use
Authorization Code (default)authorization_codeA person signs in to the provider and grants access. Blokkio uses PKCE (S256) and a one-time state.
Client Credentialsclient_credentialsServer-to-server access with the app's own credentials, no sign-in.
PasswordpasswordExchanges a username and password for a token. Only for providers that still require it.
Refresh Tokenrefresh_tokenYou already have a refresh token. Blokkio uses it to get access tokens.

Fields​

The fields come from the app (for Any REST API → OAuth 2.0, the generic OAuth 2.0 template; for a custom app, the parameters you defined). These parameter keys have a special meaning:

KeyDescription
auth_urlAuthorization endpoint (authorization code only).
access_token_urlToken endpoint. Required.
refresh_token_urlEndpoint for refreshing tokens. Defaults to access_token_url.
client_id / client_secretYour app's credentials.
scopeSpace-separated scopes.
grant_typeSee the table above. Defaults to authorization_code.
client_authenticationHow the client credentials are sent to the token endpoint: header (HTTP Basic, default) or body.
token_placementWhere the access token goes on API requests: header (default) or query.
token_query_paramQuery parameter name when token_placement is query. Default access_token.
header_prefixAuthorization scheme. Default: the definition's token type, otherwise Bearer. An empty value sends the raw token.
username / passwordResource-owner credentials (password grant only).
refresh_tokenAn existing refresh token (refresh-token grant only).

Any other parameter is sent as defined (header, query or body) on the authorize, token or refresh call, based on the phases chosen in the app. A custom app can also map where the tokens are in the token response (for example data.access_token). By default Blokkio reads the standard access_token, refresh_token and expires_in fields. Both JSON and form-encoded token responses are accepted.

client_secret and other credential fields can reference a project secret with Use secret (secret://NAME); see Secrets vs. connections.

Authorizing a connection​

One click (platform OAuth app):

  1. Go to Apps, open the app (for example GitHub) and click Sign in on its OAuth option.
  2. A popup opens at the provider. Sign in and grant access.
  3. The popup closes and a toast confirms the connection, for example GitHub connected.

Your own OAuth app:

  1. Go to Apps, open Any REST API on the Generic tab (or your custom app) and click Connect on OAuth 2.0.
  2. Enter a name and fill in the fields: endpoints, client ID and secret, scopes. Click Create.
  3. A popup opens at the provider's sign-in page. Sign in and grant access. The popup closes and the connection is Healthy.

If you close the popup, the connection is saved but Not authorized. Use Re-authenticate in its ⋯ menu on the Connections page to finish later. A pending authorization expires after 10 minutes.

For the client-credentials and password grants there is no popup: Blokkio requests a token when you save, and shows the provider's error if the credentials are wrong.

Token refresh​

  • Proactive refresh. Access tokens are treated as expired 60 seconds early (but never before half their lifetime), so Blokkio refreshes them before a request would fail.
  • One refresh at a time. Refreshes are serialized per connection, so parallel runs don't race each other or invalidate each other's refresh tokens.
  • 401 → refresh → retry. If an HTTP Request made with the connection gets 401 Unauthorized, Blokkio forces a token refresh and retries the request once. If it is still rejected, the connection is marked Auth failed.
  • No refresh token. If the access token has expired and there is no refresh token, the node fails with The access token has expired and no refresh token is available. Re-authorize the connection. For the password grant, Blokkio falls back to signing in again with the stored username and password.

Troubleshooting​

ProblemFix
Provider shows "redirect_uri mismatch"Register exactly https://api.blokkio.com/api/connections/oauth2/callback with the provider.
The connection has no access token URL (access_token_url).Fill in the token endpoint.
The token response did not contain an access token at '…'The provider uses a non-standard response. Fix the token mapping in your custom app.
Connection keeps going to Auth failedThe refresh token was revoked. Use Re-authenticate.
Request fails with "may only be used with …"The API host is not in the app's allowed domains.
Sign-in with … isn't configured on this server yetThe platform has no OAuth app for this service. Use the app's token option, or your own OAuth app.

Use Test connection to check the setup end to end. Official apps call their test request (for GitHub, GET /user); for a custom app, set a Test request such as the provider's "current user" endpoint. See Test request.