Skip to content

OAuth2 API

OAuth2 flow integration guide for AgeVerif's age verification process.

Requirements

The full OAuth 2.0 Authorization Framework RFC can be found here.

Flow Example

  1. A new visitor enters your website.

  2. The visitor clicks on the "Verify with AgeVerif" button on your website.

  3. You open a new window and redirect the visitor to AgeVerif's Authorization endpoint.

    http
    GET https://www.ageverif.com/oauth2/checker
        ?response_type=code
        &client_id=[client_id]
        &redirect_uri=https://www.example.org/oauth2-callback
        &scope=read
        &state=[state]
  4. The visitor accepts the authorization prompt and verifies their age on AgeVerif.

  5. The visitor is redirected to the given redirect_uri with code and state parameters.

    http
    GET https://www.example.org/oauth2-callback
        ?code=[code]
        &state=[state]
  6. You verify the state and exchange the code for an access_token by contacting AgeVerif's Token endpoint.

    bash
    curl -X POST https://www.ageverif.com/api/oauth2/token \
        -H "Authorization: Basic [base64(client_id:client_secret)]" \
        -H "Content-Type: application/x-www-form-urlencoded" \
        -d "grant_type=authorization_code" \
        -d "code=[code]" \
        -d "redirect_uri=https://www.example.org/oauth2-callback" \
  7. (Optional) You use the access_token to request visitor resources from AgeVerif's Resources endpoint.

    Obtaining "resources" is optional

    If you get a valid response from the previous step, the visitor is guaranteed to be verified.

    The only visitor resource available is verified.

    This endpoint exists to comply with the OAuth2 specification and to allow for future resources.

    bash
    curl -X GET https://www.ageverif.com/api/oauth2/resources \
        -H "Authorization Bearer [access_token]"
  8. You should now allow the visitor to access the content on your website.

⏳ Access Token Duration

The access_token is valid for 1 hour

Button Style Guidelines

You can choose between two flows:

  • Age Verification Flow - Opens AgeVerif's age verification process.

  • Login Flow - Opens AgeVerif's login page.

Interchangeable flows

These two flows can be used interchangebly. The visitor can still verify their age on the login flow or login on the age verification flow. The only difference is the landing page.

Logo, Colors and Shape

You can use the following colors for the button background:

  • AgeVerif Blue: #004db3
  • White: #ffffff
  • Black: #000000
  • Neutral shades of gray (non-color accents): E.g. #e0e0e0

You must use one of the AgeVerif logos provided below and ensure its visibility depending on the button's background color.

Download Button Icons

The button label/text must be clearly visible with a good contrast ratio against the button background color.

The shape of the button can be whatever you want, in line with your website's design.

The button label must be in the language of your website and should be clear and concise. Here are some allowed button labels to use on your website:

Login Flow

Language
enContinue with AgeVerifLogin with AgeVerifSign in with AgeVerif
frContinuer avec AgeVerifConnexion avec AgeVerifS'identifier avec AgeVerif
ptContinuar com AgeVerifIniciar sessão com AgeVerifFazer login com AgeVerif
esContinuar con AgeVerifIniciar sesión con AgeVerifIdentificarse con AgeVerif
itContinua con AgeVerifAccedi con AgeVerifIdentificati con AgeVerif
deFortfahren mit AgeVerifAnmelden mit AgeVerifIdentifizieren mit AgeVeri

Age Verification Flow

Language
enVerify with AgeVerifVerify age with AgeVerifProve age with AgeVerif
frVérifier avec AgeVerifVérifier l'âge avec AgeVerifProuver l'âge avec AgeVerif
ptVerificar com AgeVerifVerificar idade com AgeVerifProvar idade com AgeVerif
esVerificar con AgeVerifVerificar edad con AgeVerifProbar edad con AgeVerif
itVerifica con AgeVerifVerifica età con AgeVerifProva età con AgeVerif
deÜberprüfen mit AgeVerifAlter überprüfen mit AgeVerifAlter nachweisen mit AgeVeri

Endpoints

The OAuth2 flow consists of three endpoints:

  1. Authorization - The visitor is redirected to AgeVerif's authorization page to accept/deny the authorization request.
  2. Token - You exchange the authorization code for an access_token to be used in the next step.
  3. Resources (optional) - You can request visitor resources using the access_token obtained in the previous step.

1. Authorization

The process must be initiated with a click from the visitor on a "Verify with AgeVerif" button.

The website must open a new window to the Authorization endpoint:

http
GET https://www.ageverif.com/oauth2/checker

Optionally, you can use the login endpoint, initialized with a click from the visitor on a "Login with AgeVerif" button.

http
GET https://www.ageverif.com/oauth2/login

Parameters

FieldTypeFormatDescription
client_idstringE.g. V61LHMuuwahgYDcGnagsoYour website's Oauth2 Live Client ID, found in the Webmasters Platform
redirect_uristringE.g. https://www.example.org/oauth2-callbackCallback URI where visitor will be redirected after accepting/denying authorization. Recommended to URL-encode this parameter.
response_typestringE.g. code
Default: code
Response type. Only code is available at the moment
scopestring (optional)E.g. read
Default: read
Permission scope. Only read is available at the moment
statestring (optional)E.g. abc123Optional string to verify state was kept between calls
languagestring
(optional)
E.g. en
Available: auto,de,en,es,fr,it,pt
Default: auto
Forces a given language.
Auto is based on the visitor's browser language, with fallback to en if not available.
challengescomma separated string
(optional)
E.g. selfie,email_age,ticket
Available: selfie, email_age, credit_card, ticket, anonymage, pleenk
Loads only the given challenges.
If only one is provided, the Checker will land on that challenge.

Redirect URI parameter

It is recommended to URL-encode this parameter.

E.g. https://www.example.org/oauth2-callback becomes https%3A%2F%2Fwww.example.org%2Foauth2-callback.

State parameter

It is your responsibility to verify the state value was kept when the visitor is redirected to redirect_uri to prevent CSRF attacks.

Response

After accepting/denying authorization, the visitor is redirected to the given redirect_uri with the same state sent in the initial request and a code to be used in the Token endpoint.

The code is valid for 10 minutes.

https://www.example.org/oauth2-callback
?code=[code]
&state=[state]
FieldTypeFormatDescription
codestringE.g. 8f0FwyzmlDSfdOiE...Used on next step to exchange for an access_token
statestring (optional)E.g. abc123Optional string to verify state was kept between calls

Example

  1. The website opens a new window to:
http
https://www.ageverif.com/oauth2/checker
  ?client_id=V61LHMuuwahgYDcGnagso
  &redirect_uri=https%3A%2F%2Fwww.example.org%2Foauth2-callback
  &response_type=code
  &scope=read
  &state=abc123
  1. The visitor accepts the prompt on AgeVerif website.

  2. The visitor is redirected back to:

http
https://www.example.org/oauth2-callback
  ?code=8f0FwyzmlDSfdOiEaTjxJPXBeBEfCYrvkLyrHoM3DRZMvbaiBciebOgKfKjwWCwk
  &state=abc123
  1. The website verifies the state against the one sent in the initial request and proceeds to the next step.

2. Token

After the visitor's verification and a successful redirection to your redirect_uri, the website must exchange the authorization grant code obtained in the previous step with an access_token.

http
POST https://www.ageverif.com/api/oauth2/token

Headers

FieldTypeFormatDescription
AuthorizationstringE.g. Basic [base64(client_id:client_secret)]Basic authentication header with your Oauth2 Live Client ID and Client Secret, found in the Webmasters Platform

Information about Basic Access Authorization can be found here.

Parameters

Content-Type: application/x-www-form-urlencoded

FieldTypeFormatDescription
grant_typestringauthorization_codeProvided authorization grant type. Only authorization_code is available at the moment
codestringE.g. 8f0FwyzmlDSfdOiE...Authorization grant code returned from previous step
redirect_uristringE.g. https://www.example.org/oauth2-callbackMust be the same used in the previous authorization prompt

Client Authentication

You can authenticate either by Authorization header or by sending client_id and client_secret as parameters in the request body.

Response

The response contains an access_token and a token_type that can be used in the next step (optional).

Content-Type: application/json

js
{
  "token_type": "Bearer",
  "access_token": [access_token],
  "expires_in": [expires_in]
}
FieldTypeFormatDescription
token_typestringBearerHint for how token should be used. Only Bearer is available
access_tokenstringE.g. eyJ0eXAiOiJKV1Qi...Used to fetch user data on Resources endpoint
expires_inintE.g. 3600Seconds until token expires

Example

  1. The website sends a request with the code obtained in the previous step to the Token endpoint:

    bash
    curl -X POST https://www.ageverif.com/api/oauth2/token \
        -H "Authorization: Basic V61LHMuuwahgYDcGnPC5bbWobLw7BzR..." \
        -H "Content-Type: application/x-www-form-urlencoded" \
        -d "grant_type=authorization_code" \
        -d "code=8f0FwyzmlDSfdOiE..." \
        -d "redirect_uri=https://www.example.org/oauth2-callback" \

    Response:

    js
    {
      "token_type": "Bearer",
      "access_token": "eyJ0eXAiOiJKV1Qi...",
      "expires_in": 3600
    }
  2. (Optional) You receive an access_token and can now use it to request visitor resources on the Resources endpoint.

3. Resources (optional)

After obtaining the access_token, you can use it to request visitor resources.

http
GET https://www.ageverif.com/api/oauth2/resources

Obtaining "resources" is optional

If you get a valid response from the previous step, the visitor is guaranteed to be verified.

The only visitor resource available is verified.

This endpoint exists to comply with the OAuth2 specification and to allow for future resources.

Headers

FieldTypeFormatDescription
AuthorizationstringE.g. Bearer eyJ0eXAiOiJKV1Qi...access_token returned from previous step

Parameters

FieldTypeFormatDescription
resourcesarray(string) (optional)verifiedArray with visitor resources to return. Only verified available

Response

js
{
  "resources": [resources]
}
FieldTypeFormatDescription
resourcesarray(key, value)E.g. {"verified": true}Requested resources

Example

  1. The website sends a request to the Resources endpoint with the access_token obtained in the previous step:

    bash
    curl -X GET https://www.ageverif.com/api/oauth2/resources \
        -H "Authorization: Bearer eyJ0eXAiOiJKV1Qi..."

    Response:

    js
    {
      "resources": { "verified": true }
    }