Skip to content

Sign in with Canverly

“Sign in with Canverly” lets your app recognize who a person is without yet another password. People with a Canverly account sign in with one click. People without one create it in the middle of the flow, with the two factors Canverly always requires.

This guide covers identity only (scopes openid profile email). For your app to act on the person’s sites (read and publish articles, for example) without anyone generating an API key, read Connect Canverly next. Both fit in the same click. The identity scopes (openid, profile, email) did not change; the full catalog, with the fine scopes of Connect, is in App scopes.

You want to Use
Know who the person is and give them an account in your app Sign in with Canverly (this guide)
Call the Canverly API on the person’s behalf Connect Canverly
Your own automation on your own site, no person involved API key

sub is per sector (pairwise). The id_token sub is not the person’s internal id. Apps in the Canverly group share one sub (the person is recognized across them). Each partner gets its own sub: two partners cannot correlate the same person. Treat sub as opaque text of up to 64 characters; your account key is the pair (iss, sub).

Email is never identity. A person can have several emails and change the primary one. The email claim is for contact, not for finding accounts. Store (iss, sub).

amr and acr tell you how the person signed in. Canverly never authenticates with fewer than two factors. amr uses RFC 8176 values (pwd, otp, hwk, swk, mfa, mail) and acr is urn:canverly:acr:aal2 (two distinct factors) or urn:canverly:acr:aal3 (passkey with user verification). If your app needs strong proof for a sensitive action, send acr_values in the request and check the returned acr. To force a recent login use max_age.

Today the Canverly team registers apps (there is no dynamic registration). To request one, send the group’s technical contact:

  • name, a short description (up to 400 characters) and a logo as PNG or WebP up to 256 KB (SVG is not accepted);
  • the site address (site_url), the app’s privacy policy and terms of use, and the name of the company responsible (they show on the consent screen). site_url must be https, with no username and password and no fragment. If the app also uses Connect, site_url should be a page of yours that starts “Connect”: that is where the “Connected apps” panel sends the person on “Update permissions” (details);
  • the exact redirect URIs, one per line. Rules: https, no wildcard, no fragment. In production localhost and http are dropped. Matching is exact string comparison;
  • the scopes the app needs (for login: openid profile email);
  • whether the app is confidential (it has a server that keeps a secret) or public. Always sign in through your server.

You receive a client_id and, if confidential, a secret shown exactly once. Keep it as a server environment variable. Never in the browser, in NEXT_PUBLIC_* or in a repository. Rotation supports an overlap window (default 24 hours) so you can swap without breaking sign-in.

Janela do terminal
curl -s https://auth.canverly.net/.well-known/openid-configuration

Read authorization_endpoint, token_endpoint, jwks_uri and userinfo_endpoint from there instead of hard-coding paths. The document also lists scopes_supported, subject_types_supported and code_challenge_methods_supported. The same document is served at /.well-known/oauth-authorization-server (RFC 8414), for libraries that only speak OAuth. Only when the environment offers Connect does it carry revocation_endpoint, introspection_endpoint, refresh_token in grant_types_supported and the API scopes in scopes_supported; without it those fields are absent.

3. Step by step: authorization code with PKCE

Section titled “3. Step by step: authorization code with PKCE”
  1. Prepare the request on the server. Generate, with a cryptographic random generator, state (ties the request to the browser), nonce (ties the id_token to the request) and code_verifier (43 to 128 characters). Compute code_challenge = base64url(SHA-256(code_verifier)). Keep the three in the server session, bound to the browser by an HttpOnly, Secure, SameSite=Lax cookie.

  2. Redirect the person to authorization_endpoint:

    GET /oauth/authorize
    ?response_type=code
    &client_id=YOUR_CLIENT_ID
    &redirect_uri=https%3A%2F%2Fyourapp.example%2Fauth%2Fcanverly%2Fcallback
    &scope=openid%20profile%20email
    &state=...&nonce=...
    &code_challenge=...&code_challenge_method=S256

    state and nonce are mandatory with openid. PKCE S256 is mandatory (plain is refused). A scope the app is not allowed to request is an invalid_scope error, not silently ignored.

  3. Canverly handles the rest. With no session, the person signs in (or creates an account) and returns to the request. Group apps with identity consent already given proceed without a screen. For partners and for the first time, the person sees the consent screen with the app’s name and responsible company. prompt=login and prompt=consent force the screens.

  4. Receive the callback on your redirect URI: code, state and iss. Check that state is the one you stored and that iss is the expected issuer (RFC 9207). If error arrives, show a message of your own and do not loop the request. The code lives 60 seconds and works once: reusing it revokes what it already issued.

  5. Exchange the code for tokens, server to server:

    Janela do terminal
    curl -s https://auth.canverly.net/oauth/token \
    -u "$CANVERLY_CLIENT_ID:$CANVERLY_CLIENT_SECRET" \
    -d grant_type=authorization_code \
    -d code="$CODE" \
    -d redirect_uri="https://yourapp.example/auth/canverly/callback" \
    -d code_verifier="$CODE_VERIFIER"

    A confidential client authenticates with HTTP Basic (client_secret_basic) or client_secret_post; the server accepts both for any confidential app, pick one. With Basic, client_id and secret go application/x-www-form-urlencoded before the base64 (RFC 6749 §2.3.1; the secrets Canverly issues are base64url, so there is nothing to encode and the curl -u above works; the ready examples already encode). With client_secret_post, id and secret go in the body: in the query string they do not authenticate. Each parameter counts once (a repeated one is invalid_request). The response carries access_token, id_token, token_type, expires_in and scope.

  6. Validate the id_token before trusting it (next section), then open your app’s session.

The id_token is a signed JWT (today EdDSA; the JWKS states each key’s algorithm by kid). Accept only algorithms from the list you expect, never whatever the token declares unchecked. Check, in this order:

Check Rule
Signature Key from jwks_uri with the same kid. Cache the JWKS and refetch, rate-limited, when an unknown kid shows up.
iss Equals the discovery issuer.
aud Contains your client_id. With more than one value, azp must be your client_id.
exp and iat Not expired (clock skew up to 60 seconds). Lifetime is 10 minutes.
nonce Equals what you stored in step 1.
sub Present. Your account key is (iss, sub).

Claims by scope: profile brings name, locale and picture (when present); email brings email (the verified primary) and email_verified. auth_time, amr, acr and sid also come. The id_token is for your app; it never works to call the Canverly API.

To read the data again later, userinfo_endpoint (GET or POST, with Authorization: Bearer) accepts the login access_token and returns the same claims by scope. It refuses a token issued to another app and a revoked grant, always with 401 and WWW-Authenticate: Bearer. When the request includes API scopes (Connect), the access_token is opaque (cvt_) and userinfo does not accept it: read the claims from the id_token.

Section titled “5. Link the Canverly account to your app’s account”
  1. First login with an (iss, sub) you have never seen and no account of yours with the same email: create the app account and store (iss, sub).
  2. An account of yours with the same email already exists: do not merge on your own. Ask for the existing account’s login (proof the person owns it) and only then store (iss, sub). Merging by email without that proof allows account takeover by whoever controls a look-alike email.
  3. Require email_verified: true before using the email for anything.
  4. Later logins: find the account by (iss, sub), ignore email changes, and update the name only if the person wants.

Ending the session in your app does not end the Canverly session (other group apps stay signed in). Ending it at Canverly is irreversible and invalidates the session on the server.

App-initiated logout (end_session_endpoint) and back-channel logout (backchannel_logout_uri) are available on .net, not yet on .com. See Logout (end_session and back-channel). Where the environment does not advertise end_session_endpoint in discovery, treat your app session as yours and renew the id_token when you need recent proof.

Symptom Likely cause
Canverly error screen (does not return to your app) redirect_uri differs from the registered one, unknown client_id, or app disabled. For safety Canverly never redirects to an unverified address.
invalid_request Missing state, nonce (with openid), code_challenge or code_challenge_method=S256, or a repeated parameter. request and request_uri return request_not_supported and request_uri_not_supported.
invalid_scope You requested a scope the app does not have. Ask the team to adjust the registration.
invalid_grant at /oauth/token code used twice, expired (60 s), or redirect_uri or code_verifier differ from step 2.
invalid_client Wrong secret, a disabled app or a request with no client credentials. Comes with 401 and WWW-Authenticate: Basic.
id_token fails on nonce You reused a nonce across requests or lost the session between round trip (a SameSite=Strict cookie drops the return; use Lax).
Unknown kid The key rotated. Refetch the JWKS (once, rate-limited) and try again.

Minimal servers, no published package and no embedded secret (everything comes from environment variables). Each does authorization code with PKCE, token exchange, id_token validation, refresh, an API call and revocation:

The endpoint contract is in /rascunhos/oauth-apps-openapi.yaml (a draft of the contract, not yet generated from the service).