Authentication & Tokens
The Authentication API allows you to authenticate users on your end and redirect them as authenticated users back to vivenu. After successful login on your end, you should issue an exchange token and redirect the user back to the appropriate page.
Create an exchange token
Create an exchange token
After issuing an exchange token, you should redirect the user back to the vivenu to be logged in.
The url the user should be redirected to can be created as follows.
Append the recently created token as exchangeToken query parameter to the redirect_uri.
Notice: redirect_uri is a query param that we provide when we request a login.
Request
const response = await fetch('https://vivenu.com/api/auth/exchange-token', {
method: 'POST',
headers: {
Authorization: 'Bearer {token}',
'Content-Type': 'application/json',
},
body: JSON.stringify( {
"resourceType": "customer",
"customerId": "507f191e810c19729de860ea"
}),
})
const data = await response.json()Response (200)
{
"exchangeToken": "string",
"expiresIn": 900
}Exchange a token
Exchange a token
In order to receive an access token, you need to provide the created exchange token to this endpoint. This might be useful if you need to access authenticated customer APIs in order to create your own account experiences.
Payload
Required attributes
- Name
exchangeToken- Type
- string
- Description
The token to be exchanged for an access token
Request
const response = await fetch('https://vivenu.com/api/auth/token', {
method: 'POST',
headers: {
Authorization: 'Bearer {token}',
'Content-Type': 'application/json',
},
body: JSON.stringify( {
"exchangeToken": "string"
}),
})
const data = await response.json()Response (200)
{
"token": "string",
"expiresIn": 3600
}Returning to vivenu
Notice: You do not need to know the details of this endpoint when you redirect the user back to vivenu using the redirect_uri parameter, as described in the section above.
In case you do not have a redirect_uri, for example when initiating the authentication process yourself (redirecting a user from your page to vivenu), this is the endpoint you should redirect the user to.
The redirect_uri you need to provide for this endpoint will be the url the user should be redirected on when the authentication process is complete. This could be the url of your seller page, for example.