Skip to main content
This is not the recommended way to authenticate. For most integrations, use a personal API token: it is simpler and needs no setup on our side. Choose OAuth 2.0 only if you need each workspace to authorize your application itself.
Enterprise feature. OAuth 2.0 is available on the Enterprise plan. Contact your Penbox account manager to enable it.
Use OAuth 2.0 when you build an integration used by several Penbox workspaces (a partner platform, a marketplace app). Each workspace admin authorizes your application once, and you receive a Bearer token for that workspace, without ever handling a personal API token.
OAuth 2.0 clients are provisioned by Penbox. There is no self-service screen to create one yet. Contact support@penbox.io with your application name, logo, website and the HTTPS redirect URI(s) you will use. You receive a client_id and a client_secret in return.

How it works

Penbox supports the Authorization Code flow, with refresh tokens.
The client_secret must stay on your server. Never ship it in a browser app or a mobile app.

Endpoints

The authorization and token endpoints live at the root of the host, not under /v1. The server metadata is published at /.well-known/openid-configuration.

Step 1: Send the user to Penbox

Redirect the user’s browser to /authorize:
The user signs in, selects the workspace to authorize, and approves your application.

Step 2: Receive the authorization code

Penbox redirects the user back to your redirect_uri:
Check that state matches what you sent. If something went wrong, the redirect carries error and error_description instead of code.

Step 3: Exchange the code for tokens

Call POST /token from your server with your credentials:
The body can be JSON or application/x-www-form-urlencoded. Instead of the body, you can also send the credentials with HTTP Basic authentication (Authorization: Basic base64(client_id:client_secret)). If you sent a redirect_uri in step 1, send the same value here. Response:

Step 4: Call the API

Use the access token exactly like a personal API token:

Refreshing the access token

Before the access token expires, request a new one:
The response contains a new access_token. The refresh token stays the same, so keep storing it.
If the refresh token is rejected (400), send the workspace admin through the authorization flow again.

Errors

At the /authorize step, errors are sent back to your redirect_uri as error and error_description. If the redirect_uri itself is invalid, the error is shown to the user instead of redirecting.

Security checklist

  • Store client_secret and refresh tokens in a secrets manager, never in source control or client-side code.
  • Always send and verify state.
  • Register exact HTTPS redirect URIs.
  • Keep one access token and one refresh token per authorized workspace.
  • Ask Penbox to rotate your client_secret if it may have leaked.

Next steps

Bearer token authentication

Use a personal API token for your own workspace

Error Codes

HTTP status codes returned by the API