Table des matières

🇫🇷 Français | 🇬🇧 English


Authorization Code Flow

Objective

The Authorization Code flow is the main integration method for L’Identité Numérique La Poste.

It allows partners to:


Principle

The flow is based on a multi-step exchange:

  1. User redirection to LINLP
  2. Authentication (mobile)
  3. Return with a temporary code
  4. Exchange the code for tokens
  5. Retrieve user data

👉 This flow complies with the OpenID Connect standard.

LINLP DIAGRAM


Step 1: /authorize request

The partner redirects the user to LINLP.

GET /authorize

Main parameters:

Example:

https://authent.pprod.lidentitenumerique.laposte.fr/auth/realms/partenaire/protocol/openid-connect/auth
?client_id=XXX
&response_type=code
&redirect_uri=https://myservice.com/callback
&scope=openid+profile+email
&state=abc123
&nonce=xyz456

💡 `login_hint` can be used to prefill the user’s phone number.


Step 2: User authentication

The user:

👉 Data consent is requested when required.


Step 3: Redirection with code

After success:

https://myservice.com/callback?code=ABC123&state=abc123

⚠️ The code:


Step 4: Code exchange (/token)

The backend calls:

POST /token

Example:

grant_type=authorization_code
code=ABC123
redirect_uri=https://myservice.com/callback

👉 Authentication is required through:


Step 5: Token retrieval

Response:


Step 6: User data retrieval (/userinfo)

GET /userinfo
Authorization: Bearer access_token

👉 Returns:


🔐 Critical Recommendation

⚠️ The partner must retain the id_token

👉 Why?

👉 Use cases:

💡 Unlike the access_token, the id_token should be retained by the partner


Error Cases

/authorize errors

Case Behavior
Invalid scope Redirection with error=invalid_scope
Invalid client_id HTTP 400 error
Invalid redirect_uri HTTP 400 error

User-side errors

Case Behavior
User refusal Return to login page
Validation timeout Return to login page
Unknown user Timeout

/token errors

Case Description
Invalid code invalid_grant
Expired code invalid_grant
Invalid client_secret unauthorized_client

/userinfo errors

Case Description
Invalid token invalid_token
Expired token access denied

Best Practices

⚠️ Always use a backend

⚠️ Validate the state parameter

⚠️ Validate the nonce

⚠️ Verify the id_token signature

⚠️ Handle expirations

⚠️ Log errors


Points of Attention

⚠️ redirect_uri must match exactly

⚠️ Scopes must be declared in advance

⚠️ The flow is synchronous for the user

⚠️ Returned data depends on:


Summary


Next Step

👉 For advanced use cases:

CIBA Flow