OAuth2
SDK
We provide a PHP SDK with an example integration to make it easier and faster to get ready to verify your customers' age:
Postman Workspace
We've created a Postman workspace specifically for our API, which contains example API calls that you can use to test and familiarise yourself with our API.
The workspace includes example API calls for each of our API endpoints, along with detailed descriptions of the request parameters and headers being used.
You can generate most of the client code to call our APIs using the Postman client code generator. With this feature, developers can select a range of programming languages, and generate the corresponding code with a few clicks.
Please note that while both the example API calls and the generated code can be a helpful starting point, it's important to thoroughly test your own API calls before deploying them in production. If you encounter any issues while using the example API calls, or if you have any questions about our API, please don't hesitate to reach out to our support team.
API Domain
Our API is designed to be used in two environments: a sandbox environment and a production environment.
The sandbox environment is intended for testing and development purposes, while the production environment is used for live data and real-world use cases.
To ensure the security and integrity of our API, we use separate API keys for each environment. This means that you will need to obtain different API keys for the sandbox and production environments, and should not use the same key for both.
Domain | Environment |
---|---|
https://oauth.verifymyage.com | production |
https://sandbox.verifymyage.com | sandbox |
User Journey
Each country has different requirements for accessing adult content which are laid out by the regulator of that country.
A user is required to verify their age the first time they visit your site. They simply log in to their VerifyMyAge account for future sessions.
Integration Steps
The OAuth2 verification consists of 2 basic steps, getting a user access token and then getting user data:
1. Redirect the user to the VerifyMyAge verification flow
2. Your server performs a POST request to exchange the code for an access_token
Then, you can confirm that the user is age-verified by calling the user details endpoint using the access_token
received.
Redirect user to the flow
This will redirect the user back to the URL you've sent on the redirect_uri
query parameter with one key extra query parameter code
. This value sent will be used on the next step of the OAuth2 flow.
Request parameters
client_id required
Your API Key which can be found in your VerifyMyAge dashboard.
scope required
Constant value must be set as adult
.
redirect_uri required
URL that the user will be redirected to after the age-verification flow.
country required
2-letter ISO country code. Available options: gb, de, fr, or us.
Note: Additional options are available. Please contact us to discuss this further.
user_id optional
User's unique ID.
Error responses
Code | Description |
---|---|
400 |
|
400 |
|
400 |
|
401 |
|
500 |
|
GET /oauth/authorize?client_id=CLIENT-ID&scope=adult&country=gb&redirect_uri=https://your-domain.com/your-path HTTP/1.1
Exchange code by token
For security reasons, you'll have to send your secret key
via server-side to exchange the code for an access_token
.
Following the OAuth2 standard, you'll have to send the Authorization
header using the Basic authentication format:
The value is generated by the base64 string of the concatenation of your API Key and API Secret separated by a colon (:).
Example in PHP:
[
'Authorization' => 'Basic ' . base64_encode(
$apiKey . ':' . $apiSecret
)
]
Request parameters
code required
The code received as a query parameter to your redirect_uri in the previous step.
Error responses
Code | Description |
---|---|
400 |
|
401 |
|
401 |
|
500 |
|
POST /oauth/token HTTP/1.1
Content-Type: application/json
Authorization: Basic {BASE64}
{
"code": "CODE-RECEIVED-ON-THE-FIRST-STEP"
}
{ "access_token": "RANDOM-CODE" }
User details
You are able to get the status of the verification now.
Request parameters
access_token required
The token generated by VerifyMyAge in Step 2.
Response parameters
age_verified
Boolean that represents whether the user completed the process or not.
Value | Description |
---|---|
true | The user has completed the verification process successfully. |
false | The user has not completed the verification process successfully |
id
Unique Identifier representing a verification.
threshold
The age threshold the user has to meet. It is a fixed value of 18.
Error responses
Code | Description |
---|---|
400 |
|
500 |
|
500 |
|
500 |
|
GET /users/me?access_token={TOKEN} HTTP/1.1
{ "age_verified": true, "id": "ABC-12345-DEF-64321", "threshold": 18 }
Allowed Redirect URLs
URLs that are allowed to be redirected to after a successful verification.
Generating the HMAC header
To improve the security of the communication between your implementation and the VerifyMyAge API, we require you to generate a unique hexadecimal encoded SHA256 HMAC hash for each request, based on the input parameters.
The process of generating it depends on the language of your implementation.
<?php
hash_hmac('sha256', $input, 'API_SECRET');
Get allowed URLs
Retrieve a list of allowed redirect URLs.
Authorization Header
Generate HMAC with: Request URIAuthorization: hmac YOUR-API-KEY:GENERATED-HMAC
Response parameters
body
The list of Allowed Redirect URLs.
Error responses
Code | Description |
---|---|
401 |
|
500 |
|
GET /v1/business/allowed-redirects HTTP/1.1
Content-Type: application/json
Authorization: hmac YOUR-API-KEY:GENERATE-HMAC-WITH-REQUEST-URI
{ "body": [ "https://your-website.com/redirect-1", "https://your-website.com/redirect-2" ] }
Add Allowed URLs
Add one or more allowed redirect URLs.
Authorization Header
Generate HMAC with: Request BodyAuthorization: hmac YOUR-API-KEY:GENERATED-HMAC
Request parameters
body required
An array containing the allowed redirect URLs.
Error responses
Code | Description |
---|---|
401 |
|
500 |
|
PATCH /v1/business/allowed-redirects HTTP/1.1
Content-Type: application/json
Authorization: hmac YOUR-API-KEY:GENERATE-HMAC-WITH-REQUEST-BODY
[
"https://your-website.com/redirect-1"
]
Replace All Allowed URLs
Replace any existing allowed redirect URLs with the provided list.
Authorization Header
Generate HMAC with: Request BodyAuthorization: hmac YOUR-API-KEY:GENERATED-HMAC
Request parameters
body required
An array containing the allowed redirect URLs.
Error responses
Code | Description |
---|---|
401 |
|
500 |
|
PUT /v1/business/allowed-redirects HTTP/1.1
Content-Type: application/json
Authorization: hmac YOUR-API-KEY:GENERATE-HMAC-WITH-REQUEST-BODY
[
"https://your-website.com/new-redirect-url"
]
Delete Allowed URLs
Remove one or more allowed redirect URLs.
Authorization Header
Generate HMAC with: Request BodyAuthorization: hmac YOUR-API-KEY:GENERATED-HMAC
Request parameters
body required
An array containing the allowed redirect URLs.
Error responses
Code | Description |
---|---|
401 |
|
500 |
|
DELETE /v1/business/allowed-redirects HTTP/1.1
Content-Type: application/json
Authorization: hmac YOUR-API-KEY:GENERATE-HMAC-WITH-REQUEST-BODY
[
"https://your-website.com/redirect-1",
"https://your-website.com/redirect-2"
]
Demo
You can try a demo of this integration at: