Initiate Session
For a user to go through Verisoul's verification, the frontend SDK must be initialized with a valid session token.
Note: Each session token is short lived and used to establish the authenticity throughout the session
To get a session token, your application's server can make an API request to Verisoul like below. Note, for security it is best practice to generate the session token from a protected server, not on the client.
/*BACKEND*/
try {
// Create a session token via Verisoul's API
let response = await fetch('https://api.verisoul.xyz/session', {
method: 'POST',
x-api-key: {VERISOUL_API_KEY}
});
if (!response.ok) {
throw new Error(`failed to create Verisoul session: ${response.status}`);
}
let {sessionToken} = await response.json();
} catch (err) {
console.error(err);
}
The newly created session token must be passed to Verisoul's frontend SDK in order to begin verifying a user. If an expired or non valid session token is passed the user will not be able to begin a verification altogether.
/*FRONTEND*/
return (
<div>
...
{sessionToken
? <Verisoul session={sessionToken}
onComplete={...}
environment={...}/>
: null
}
</div>
);
Last modified 8mo ago