OAuth 2.1 token endpoint
const url = 'https://app.buildworkpro.com/api/v1/oauth/token';const options = { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: new URLSearchParams({ grant_type: 'authorization_code', code: 'example', redirect_uri: 'example', client_id: 'example', client_secret: 'example', code_verifier: 'example', refresh_token: 'example', scope: 'example' })};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.buildworkpro.com/api/v1/oauth/token \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=authorization_code \ --data code=example \ --data redirect_uri=example \ --data client_id=example \ --data client_secret=example \ --data code_verifier=example \ --data refresh_token=example \ --data scope=exampleExchanges an authorization code (with PKCE verifier) or a refresh token for a new access token (and rotated refresh token). Body MUST be application/x-www-form-urlencoded per RFC 6749. Response carries Cache-Control: no-store. Confidential clients authenticate by passing client_secret in the body; public clients omit it. Refresh token reuse triggers family-wide revocation of all access + refresh tokens issued from the original grant.
Request Body
Section titled “ Request Body ”object
OAuth 2.1 grant type. Supported: authorization_code, refresh_token.
Example
authorization_codeAuthorization code (required for grant_type=authorization_code).
Must exact-match the redirect_uri originally used to obtain the code.
OAuth client identifier issued by the registration endpoint.
Required for confidential clients; MUST be omitted for public clients.
PKCE verifier (S256). Required for grant_type=authorization_code.
Refresh token (required for grant_type=refresh_token).
Optional space-separated scope list. For grant_type=refresh_token, MUST be a subset of the original refresh token’s scopes (scope downgrade only). Upgrade is rejected with invalid_scope.
Responses
Section titled “ Responses ”Access token issued
object
Example
{ "token_type": "Bearer"}RFC 6749 §5.2 error envelope (invalid_request, invalid_grant, invalid_client, unsupported_grant_type)
object
Example generated
{ "error": "example", "error_description": "example"}Client authentication failed (invalid_client)
object
Example generated
{ "error": "example", "error_description": "example"}