DocID®DocID® Documentation
Back to DocID®
  • Overview

    • DocID® Documentation
  • Introduction

    • Introduction
    • How DocID® works
    • Core concepts
  • Getting Started

    • Getting Started
    • Drupal module
    • WordPress plugin
    • Custom website
    • Go-live checklist
  • Features

    • Features
    • Standard Login
    • Access and personalization
    • Analytics
    • Campaigns
  • Licenses

    • Licenses
  • OAuth 2.0

    • OAuth 2.0
    • Configure a client
    • Authorization code flow
    • Scopes and UserInfo
    • Security and environments
  • API

    • API
  • Help

    • Troubleshooting

OAuth 2.0

Authorization code flow

Implement authorization, PKCE, code exchange, refresh, and logout safely.

1. Generate transaction values

For every login attempt, generate:

  • A high-entropy state value to bind the request to the callback
  • A nonce value to bind identity assertions to the request
  • A high-entropy PKCE code_verifier
  • A code_challenge, calculated as the base64url-encoded SHA-256 digest of the verifier

Store the values in a short-lived, server-protected transaction.

2. Redirect to authorization

1GET /oauth2/authorize?2  response_type=code&3  client_id=YOUR_CLIENT_ID&4  redirect_uri=https%3A%2F%2Fexample.com%2Fauth%2Fdocid%2Fcallback&5  scope=openid%20professional&6  state=RANDOM_STATE&7  nonce=RANDOM_NONCE&8  code_challenge=PKCE_CHALLENGE&9  code_challenge_method=S256

3. Validate the callback

A successful callback contains code and state. Compare state with the stored value using a timing-safe comparison where possible. Reject missing, reused, expired, or mismatched transactions.

An unsuccessful callback contains error and may contain error_description. Log only a safe internal correlation ID and show the user a recoverable message.

4. Exchange the code

Send a server-to-server form request:

1POST /oauth2/token2Content-Type: application/x-www-form-urlencoded3Authorization: Basic BASE64_CLIENT_ID_AND_SECRET45grant_type=authorization_code&6code=RETURNED_CODE&7redirect_uri=https%3A%2F%2Fexample.com%2Fauth%2Fdocid%2Fcallback&8code_verifier=ORIGINAL_PKCE_VERIFIER

Client credentials may also be accepted in the form body where configured, but HTTP Basic keeps credentials separate from the grant parameters.

5. Read user information

1GET /oauth2/userinfo2Authorization: Bearer ACCESS_TOKEN

Use the response to create a local website session, then remove the one-time OAuth transaction.

Refresh and revoke

Exchange a valid refresh token with grant_type=refresh_token at /oauth2/token. Store refresh tokens only on the server. When the integration no longer needs a token, revoke it at /oauth2/revoke and invalidate the local session.

PreviousConfigure a clientNextScopes and UserInfo

On this page

  1. 1. Generate transaction values
  2. 2. Redirect to authorization
  3. 3. Validate the callback
  4. 4. Exchange the code
  5. 5. Read user information
  6. Refresh and revoke