Authentication & Authorization
Hive uses the OAuth 2.0 Authorization Code Flow with PKCE to issue access tokens. This flow is required for every integration.
The Client Credentials Flow is not supported. Only the Authorization Code Flow with PKCE is supported.
Required headers
Every API request needs both headers:
X-Partner-Id is validated by the API gateway. Requests with a missing or invalid value are rejected before they reach the API, so if a request fails this way, check the header.
Access tokens are scoped to a single brand. All data read or written through the API is automatically associated with the brand that authorized the token, so you don’t provide a brand identifier in requests.
What you need
During onboarding, Hive provides:
- Your OAuth client ID (also used as the
X-Partner-Idheader) - Your OAuth client secret
- The authorization endpoint
- The token endpoint
You provide Hive with one or more callback (redirect) URLs where users are sent after authorizing your app. You can manage these in the Partner Portal. Only registered callback URLs are accepted.
OAuth endpoints
Hive’s OAuth implementation uses two domains:
app.hive.co: user authorization (the user signs in to Hive)api.hive.co: token management and API access
Authorization flow
Redirect the user to Hive
Send the user to the authorization endpoint with your client_id, requested scopes, and a
PKCE code_challenge.
Authorization request
After the user grants access, Hive redirects to your callback URL with an authorization code:
Verify that state matches the value you sent before exchanging the code.
Brand selection
On the consent screen, the user picks a brand they administer. Each token is scoped to that one brand; to connect multiple brands, run one authorization per brand.
If you pass tour_id, that brand is preselected. An invalid tour_id returns 400 Bad Request; a brand the user doesn’t administer returns 403 Forbidden.
If the user has already authorized your app with the same scopes and still has an unexpired access token, the consent screen is skipped and Hive redirects immediately, reusing the previously authorized brand.
Token response
Scopes
Scopes define the permissions your application requests. You must include scopes in the authorization request, or the issued access token won’t have permission to access the API.
Pass scopes as a space-separated list in the scope parameter. We strongly recommend requesting all of them, so the user authorizes read and write access to every available resource:
Token lifecycle
- Access tokens are valid for 1 hour (3600 seconds). Refresh proactively using the
expires_invalue rather than waiting for a401. - Refresh tokens rotate on every use. Each refresh returns a new access token and a new refresh token, which you must store. The previous refresh token keeps working for 2 minutes after rotation (returning the same new tokens), so a refresh whose response was lost can be safely retried.
- Refresh tokens expire after 90 days of inactivity. Because each refresh issues a new refresh token, an integration that refreshes at least once every 90 days stays connected indefinitely. If your integration is seasonal or low-traffic, refresh on a schedule (we recommend at least monthly).
- An expired access token does not invalidate your refresh token. You can refresh at any time afterward.
- Re-authorization (running the full OAuth flow again) is only required if your refresh token is lost, expired, or invalidated, for example if you fail to store the new refresh token returned by a refresh.
Store these values from every token response:
access_tokenrefresh_tokenexpires_in: token lifetime in seconds
Revoking tokens
Revoke a token with POST https://api.hive.co/oauth/revoke_token/. The request requires client authentication: send token, client_id, and client_secret as form fields.
Implementation examples
Hive’s public GitHub repo contains simple reference implementations of the authorization code flow in JavaScript (Node) and Python.
You can point your preferred AI coding assistant at the repository to help you implement the authorization code flow in your own platform.
Important notes
- PKCE is required for all integrations.
- The Client Credentials Flow is not supported.
- Store tokens securely on your backend. Never expose
access_token,refresh_token, orclient_secretclient-side. - After the 2-minute grace period, a used refresh token is rejected.
- Callback URLs must be registered with Hive in advance. Unregistered URLs are rejected.
- API requests with expired or invalid access tokens return
401 Unauthorized. - A valid token missing a required scope returns
403 Forbidden. A token not issued through this OAuth flow returns403withToken is not authorized for API v2. - If the authorized brand hasn’t been set up for your integration, requests return
404 Not Found. Contact Hive to resolve it. - Refreshing with an expired or invalid refresh token returns
400 Bad Requestwith"error": "invalid_grant".