OAuth 2.1

Sign in with Hypris in your own app: server discovery, PKCE, scopes, tokens and refreshing.

On this page

OAuth 2.1 lets users sign in to your app with their Hypris account and grant it access without sharing a password or key. AI assistants connect via MCP the same way. Hypris supports the authorization code flow with PKCE and token refresh.

Key facts

Flowauthorization_code with PKCE, method S256 (plain is rejected)
Refreshrefresh_token
Client registrationClient ID Metadata Document or dynamic registration (RFC 7591)
Client authenticationnone (public client), client_secret_basic, client_secret_post, private_key_jwt (RFC 7523)
Access tokenValid for 1 hour, type Bearer
Refresh tokenValid for 30 days

Server discovery

Don't hard-code addresses. The authorization server metadata is at the standard address, on the API domain but outside the version path:

Metadata
https://api.hypris.com/.well-known/oauth-authorization-server

In it you'll find authorization_endpoint, token_endpoint, registration_endpoint, revocation_endpoint and the list of scopes in scopes_supported. The MCP server also publishes /.well-known/oauth-protected-resource, so MCP clients find the authorization server without any configuration.

Client registration

You have two options:

  • Client ID Metadata Document. As client_id you provide the HTTPS address of a JSON document describing the app. Hypris fetches it itself, so you don't need to register anything. When the document lists several methods in token_endpoint_auth_methods_supported, Hypris picks one you both support: private_key_jwt if the document publishes a key in jwks_uri or jwks, and none otherwise.

  • Dynamic registration. Send POST https://api.hypris.com/v1/oauth/register with client_name, redirect_uris and optionally token_endpoint_auth_method. With private_key_jwt, also include jwks_uri or jwks. The endpoint doesn't require sign-in, but it's limited to 10 registrations per hour from one IP address.

The flow step by step

  1. Generate a random code_verifier and compute code_challenge from it as base64url of SHA-256.

  2. Redirect the user to authorization_endpoint with the parameters response_type=code, client_id, redirect_uri, scope, state, code_challenge and code_challenge_method=S256.

  3. The user signs in, chooses a workspace and confirms the scopes on the consent screen.

  4. Hypris redirects back to redirect_uri with the code and state parameters. Check that state matches.

  5. Exchange the code for tokens at token_endpoint.

curl -X POST "https://api.hypris.com/v1/oauth/token" \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d redirect_uri="https://your-app.com/callback" \
  -d client_id="$CLIENT_ID" \
  -d code_verifier="$CODE_VERIFIER"

A confidential client adds its secret in the Basic header or in the client_secret field, according to the method chosen at registration.

A client with the private_key_jwt method sends a signed JWT instead of a secret, in the client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer and client_assertion fields. In the JWT, iss and sub are its client_id, aud is the token_endpoint or issuer address, and exp is at most an hour ahead. Each JWT works only once. Hypris checks the signature with the key from jwks_uri or jwks, and the supported algorithms are listed in token_endpoint_auth_signing_alg_values_supported.

Refreshing a token

Refresh
curl -X POST "https://api.hypris.com/v1/oauth/token" \
  -d grant_type=refresh_token \
  -d refresh_token="$REFRESH_TOKEN" \
  -d client_id="$CLIENT_ID"

The response contains a new pair of tokens. Always save the new refresh_token in place of the old one.

Revoking a token

Sign-out
curl -X POST "https://api.hypris.com/v1/oauth/revoke" \
  -d token="$REFRESH_TOKEN"

The user can also revoke access themselves, in their account settings, under Authorized apps.

Scopes

ScopeRequiredWhat it grants
profileyesBasic profile data
emailyesEmail address
user.workspaces.readyesThe user's list of workspaces
user.profile.writenoChanging profile data
user.status.readnoReading the user's status
user.status.writenoSetting the status
user.settings.readnoReading settings
user.settings.writenoChanging settings
workspace.mcpno, on by defaultWorking on workspace data, including through MCP tools

If you don't specify scope, the app gets only the required scopes. Separate scopes with a space.

What the app sees

The token is bound to the workspace chosen on the consent screen and can't reach any other. In that workspace, the app sees the intersection of two sets: the user's permissions and the permissions the administrator granted the app. It won't see anything the user can't see.

Errors

OAuth endpoints return errors in the RFC 6749 format, not in the usual API envelope:

400 Bad Request
{
  "error": "invalid_grant",
  "error_description": "…"
}

The most common codes are invalid_client, invalid_grant, invalid_scope, unauthorized_client and unsupported_grant_type.