Table des matières

🇫🇷 Français | 🇬🇧 English


API Examples

Objective

Present common API call examples for integrating L’Identité Numérique La Poste.

👉 The examples below are provided for illustration purposes.


User Authentication (/authorize)

Browser redirection:

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

Return After Authentication

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

Code Exchange (/token)

POST /auth/realms/partenaire/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

Body:

grant_type=authorization_code
code=AUTH_CODE
redirect_uri=https://myservice.com/callback
client_id=CLIENT_ID
client_secret=CLIENT_SECRET

/token Response

{
  "access_token": "eyJ...",
  "id_token": "eyJ...",
  "expires_in": 3600,
  "token_type": "Bearer"
}

Retrieve Data (/userinfo)

GET /auth/realms/partenaire/protocol/openid-connect/userinfo
Authorization: Bearer ACCESS_TOKEN

/userinfo Response

{
  "sub": "5577832670193",
  "given_name": "Jean Pierre",
  "family_name": "Dupont",
  "email": "jean.dupont@mail.com"
}

Certificate Validation

GET /auth/realms/partenaire/protocol/openid-connect/certs

OpenID Connect Configuration

GET /auth/realms/partenaire/.well-known/openid-configuration

CURL Example /token

curl --request POST \
--url https://authent.pprod.lidentitenumerique.laposte.fr/auth/realms/partenaire/protocol/openid-connect/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'grant_type=authorization_code' \
--data 'code=AUTH_CODE' \
--data 'redirect_uri=https://myservice.com/callback' \
--data 'client_id=CLIENT_ID' \
--data 'client_secret=CLIENT_SECRET'

CURL Example /userinfo

curl --request GET \
--url https://authent.pprod.lidentitenumerique.laposte.fr/auth/realms/partenaire/protocol/openid-connect/userinfo \
--header 'Authorization: Bearer ACCESS_TOKEN'

Best Practices

⚠️ Use Sandbox for testing

⚠️ Never expose `client_secret`

⚠️ Verify `state` on return

⚠️ Retain the `id_token`


Key Takeaways


Next Step

👉 OpenAPI reference:

Swagger