Dōrvis

Sign in

The Authorization Code flow

Dorvis is an OpenID Connect service using the Authorization Code flow. The user logs in on the Dorvis side, your server receives a code and exchanges it for an ID token.

Step by step

  1. Your app redirects the user to the Dorvis authorization endpoint with client_id, redirect_uri, scope, state and nonce.
  2. Without acr_values Dorvis shows the method selection. With it, the user goes straight to the Smart-ID, eParaksts or bank page.
  3. After a successful login Dorvis redirects the user back to redirect_uri with code and state.
  4. Your server checks state and sends the code to the token endpoint with the client credentials.
  5. The response contains an id_token and an access_token. The ID token includes the first name, last name, personal code and method used.
  6. Your server verifies the ID token signature, iss, aud, exp and nonce, and creates its own session.

Authorization request

HTTPGET
https://dorvis.eu/oidc/oauth2/auth
  ?response_type=code
  &client_id=your-client-id
  &redirect_uri=https%3A%2F%2Fexample.lv%2Fcallback
  &scope=openid%20profile
  &state=4f1c8a…
  &nonce=9b27e0…
  &code_challenge=E9Melhoa…
  &code_challenge_method=S256
  &acr_values=idp%3Asmartid
ParameterRequiredMeaning
response_typeyesAlways code
client_idyesIntegration ID from the portal
redirect_uriyesMust match the registered URI character for character
scopeyesopenid profile to receive first name, last name and personal code
staterecommendedRandom value for CSRF protection, checked on return
noncerecommendedRandom value that comes back in the ID token
code_challengerecommendedPKCE challenge with method S256
acr_valuesnoOne method, for example idp:smartid

Callback

HTTPGET
https://example.lv/callback?code=ory_ac_…&scope=openid%20profile&state=4f1c8a…

The code is valid for a short time and can be used once, so exchange it on the server straight away.

Code exchange

By default an integration uses client_secret_basic, where the credentials go in the HTTP Basic header. If your library sends them in the request body, choose client_secret_post in the integration advanced settings.

Shellclient_secret_basic
curl -X POST https://dorvis.eu/oidc/oauth2/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d redirect_uri=https://example.lv/callback \
  -d code_verifier="$CODE_VERIFIER"
Shellclient_secret_post
curl -X POST https://dorvis.eu/oidc/oauth2/token \
  -d grant_type=authorization_code \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" \
  -d code="$CODE" \
  -d redirect_uri=https://example.lv/callback

Response

JSON
{
  "access_token": "ory_at_…",
  "token_type": "bearer",
  "expires_in": 3599,
  "scope": "openid profile",
  "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6…"
}

Did not find the answer?

Write to us and a developer will reply.

Ask a question
Loading complete

We use cookies to make this website easier to use. Read our Privacy and Cookie Policy.