Skip to content

Sign in with Sangho (OAuth2)

“Sign in with Sangho” lets your platform authenticate its users through their existing Sangho account, without ever handling their password — just like “Sign in with Google”. Sangho acts as an identity provider (OAuth2 authorization code flow with mandatory PKCE), separate from the pk_/sk_ API keys that authenticate your server calls to the Sangho API.

Note

Canonical host: accounts.sangho.com. Integrations already configured on dash.sangho.com/o/… keep working (backward compatibility), but every new integration must use accounts.sangho.com.

1. Create an OAuth client

An OAuth client is created self-service from the API Keys tab of your Sangho dashboard: name, description, redirect URI. The client_secret (SANGHO_SECRET on your platform) is shown only once, at creation — store it immediately in your secrets manager.

Attention

A self-service client is never “trusted by default”: the Sangho consent screen is always shown each time a new user signs in. This is expected, not a configuration error.

2. Authorization flow (PKCE required)

StepEndpointDescription
1. Redirect the userGET /o/authorize/With client_id, redirect_uri, response_type=code, scope, state, code_challenge, code_challenge_method=S256
2. Consent—The user signs in to Sangho (if needed) and then authorizes your application
3. Callbackyour redirect_uriSangho redirects with ?code=…&state=… (check state against CSRF)
4. Exchange the codePOST /o/token/grant_type=authorization_code, code, redirect_uri, client_id, code_verifier
5. RefreshPOST /o/token/grant_type=refresh_token, refresh_token, client_id
6. RevokePOST /o/revoke_token/token, client_id — invalidates an access or refresh token

PKCE (code_challenge/code_verifier, S256 method) is mandatory, even for a confidential server-side client — the request is rejected without it. Access tokens expire after 1 hour, refresh tokens after 30 days.

3. Scopes and user profile

ScopeClaims returned by /o/userinfo/
profilename, given_name, family_name, picture
emailemail, email_verified

GET /o/userinfo/ (with Authorization: Bearer <access_token>) always returns sub: a stable, opaque identifier (UUID), never the email address — use it as the long-term identity key on your platform, since an email can change.

4. Revocation and suspension

An OAuth client owner can suspend their client from the dashboard (suspend/activate): no new authorization or token exchange is accepted for that client_id, but an access token that has already been issued remains valid until it expires naturally (no immediate retroactive revocation) — like most OAuth2 providers.

Authorization request example

text
GET https://accounts.sangho.com/o/authorize/
  ?client_id=your_client_id
  &redirect_uri=https://yourplatform.com/auth/callback
  &response_type=code
  &scope=profile email
  &state=random_csrf_value
  &code_challenge=BASE64URL(SHA256(code_verifier))
  &code_challenge_method=S256