Skip to content

Reference

OpenID Connect

Not using PHP? Identvia is a standard OpenID Connect provider. Use any certified library and point it at the issuer below.

Copy prompt for your AI agent

Using a coding agent? This prompt points it at these docs and lists the rules it must follow. Review what it writes like any other code.

You are helping me add "Sign in with Identvia" to my app (PHP). Identvia is an OpenID Connect provider.

Read these first (they are plain Markdown and are the source of truth; prefer them over anything you remember):
- https://id.identvia.com/developers/docs/quickstart.md
- https://id.identvia.com/developers/docs/oidc.md
- https://id.identvia.com/developers/docs/security.md
- Discovery: https://id.identvia.com/.well-known/openid-configuration

Stack: plain PHP 8.1+ (no framework). Use the official SDK identvia/identvia-php (composer require identvia/identvia-php, or the zip with vendor/ from https://id.identvia.com/developers/docs/php for hosts without Composer). Create identvia.php (config), login.php (redirectToSignIn), callback.php (handleCallback, then session_regenerate_id(true) and store sub) and logout.php. Read secrets from environment variables or a config file outside the web root.

Requirements:
1. Authorization code flow with PKCE (S256 only), a random state and a nonce per sign-in. No implicit flow.
2. Validate the ID token: RS256 signature from the JWKS, iss = https://id.identvia.com, aud contains my client_id, exp/iat, and the nonce.
3. Identify users by sub (it is pairwise: different for every app). Treat email as optional, because the person may choose not to share it.
4. Redirect URIs must match exactly. Keep the client secret and refresh tokens server-side; never log tokens.
5. Ask only for the scopes I need (openid, plus email/profile if used). Handle the user canceling (error=access_denied) gracefully.

Optional, only if I ask for AI-agent access later:
- AgentPass (agents acting for a user with single-use, holder-bound passes): https://id.identvia.com/developers/docs/agentpass.md
- MCP server for agent clients: https://id.identvia.com/developers/docs/mcp.md
- Token exchange, rich authorization requests and CIBA: https://id.identvia.com/developers/docs/delegation.md

Before writing code, tell me which files you will add or change. Don't invent endpoints or options that aren't in the docs; if something is unclear, ask me.

Discovery

Issuerhttps://id.identvia.com
Discoveryhttps://id.identvia.com/.well-known/openid-configuration
Authorizationhttps://id.identvia.com/oauth/authorize
Tokenhttps://id.identvia.com/oauth/token
Userinfohttps://id.identvia.com/oauth/userinfo
JWKShttps://id.identvia.com/oauth/jwks.json
Revocationhttps://id.identvia.com/oauth/revoke
End sessionhttps://id.identvia.com/oauth/logout

Rules Identvia enforces

  • Authorization code flow only (response_type=code). No implicit or hybrid flow.
  • PKCE with S256 is required for public clients (single-page, mobile and native apps) and recommended for every client. Server-side apps that authenticate with a client secret may omit it, and may also omit the nonce, as OpenID Connect allows.
  • Redirect URIs match exactly, character for character. No wildcards, no fragments. http://localhost only in Development environments.
  • Authorization codes are single use and expire after 60 seconds. Reusing a code revokes the tokens it produced.
  • ID tokens are signed with RS256. Access tokens last 10 minutes. Refresh tokens (scope offline_access) rotate on every use; replaying an old one revokes the whole chain.
  • The callback includes iss (RFC 9207). Check it.
  • sub is pairwise: each app sees a different, stable ID for the same person.

1. Authorization request

HTTP
GET https://id.identvia.com/oauth/authorize
  ?response_type=code
  &client_id=oid_…
  &redirect_uri=https%3A%2F%2Fexample.com%2Fcallback
  &scope=openid%20email%20profile
  &state=<random, 32+ bytes>
  &nonce=<random, 32+ bytes>
  &code_challenge=<BASE64URL(SHA256(code_verifier))>
  &code_challenge_method=S256

Optional: prompt=none|login|consent, max_age, login_hint.

2. Token request

HTTP
POST https://id.identvia.com/oauth/token
Authorization: Basic base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=…&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&code_verifier=…

Public clients send client_id in the body instead of a secret.

Response
{
  "token_type": "Bearer",
  "access_token": "eyJ…",
  "expires_in": 600,
  "id_token": "eyJ…",
  "refresh_token": "…",          // only with offline_access
  "scope": "openid email profile"
}

3. Validate the ID token

  1. Verify the signature with the key from the JWKS whose kid matches. Accept only RS256.
  2. iss equals https://id.identvia.com; aud contains your client ID; azp, if present, is your client ID.
  3. exp is in the future and iat is not (allow a minute of skew).
  4. nonce equals the one you sent.
  5. If you sent max_age, check auth_time.

Claims

ScopeClaims
openidsub, auth_time, amr
emailemail, email_verified (only if the user shares it)
profilename, given_name, family_name, picture, updated_at (only what the user shares)
offline_accessA refresh token

Users choose what to share on the consent screen, so a scope you asked for may still come back without its claims. Handle that.

Native and desktop apps

Register the environment as a Native & desktop app in the developer portal. Redirect URIs may use:

  • Private-use URI schemes in reverse-domain form (RFC 8252 §7.1), e.g. com.example.app:/oauth/identvia. Short schemes like myapp: are rejected.
  • Claimed HTTPS App Links (iOS Universal Links / Android App Links).
  • Loopback http://127.0.0.1:{port}/… or http://[::1]:{port}/…. Any port matches; the path must match exactly (RFC 8252 §7.3).

iOS older than 17.4: ASWebAuthenticationSession does not reliably return https:// callbacks. Prefer a private-use scheme on those versions; use Universal Links from iOS 17.4 onward.