Authentication
Learn how to generate an authentication token to access user data
Last updated
Learn how to generate an authentication token to access user data
Last updated
This guide explains how to authenticate users in your application to obtain an auth_token
, and make API requests to Verida’s services.
To access user data via Verida APIs, you must include a valid auth_token
in every request. This token can be generated using Verida's authorization endpoints and stored securely by your application for future requests.
Run the Verida App Connect Example:
You can clone and run the locally to test the authentication flow.
Inspect the source code to understand how authorization is integrated and how the auth_token
is handled.
Generate an Auth Token from the :
Sign in to the Verida AI Developer Console and open the .
in the Sandbox for quick testing and to explore scopes.
Below is a typical flow when integrating your application with Verida AI:
Generate an authentication request URL
Include the scopes you require as well as the redirectUrl
for successful authentication.
Redirect the user to the authentication request URL
The user is prompted to grant or deny your application access.
User grants access and is redirected back
If the user grants access, they are redirected to your specified redirectUrl
with an auth_token
in the query parameters.
Store the auth_token
Your application should save the token securely, either linked to the user’s account in your database or in the user’s local browser storage.
Make requests to Verida APIs
Include the token in the Authorization
header for all subsequent calls to Verida’s APIs.
To start the authentication process, build a URL that directs users to Verida’s authentication endpoint. This URL must include several query parameters:
redirectUrl
: The URL in your application that handles a successful user authentication.
payer
: Specifies who will pay for the API requests made with this auth token. Set this to either user
or app
.
Below is an example authentication request URL (URL-encoded) that includes three scopes:
Instead of automatically redirecting, you can provide a Connect button in your UI. When clicked, it sends users to the Verida authentication flow.
Replace ${authLink}
with the URL generated in the previous step.
Once the user grants your application access, they will be redirected to the redirectUrl
you specified with an auth_token
query parameter.
Example of how to capture the auth_token
in TypeScript:
Advanced Use Cases: Consider reading more about Verida’s data storage, encryption, and decentralized identity solutions to fully leverage the ecosystem.
Production Deployment: If you’re planning a production rollout, ensure you use secure storage for the auth_token
.
scopes
: An array of scopes that your application requires. The latest valid scopes can be listed via the .
Explore Additional Scopes: Visit for a comprehensive list of available scopes.