Initial Authentication
Field
Description
Making the Login Request
X-Violet-App-Id: your-app-id-here
X-Violet-App-Secret: your-app-secret-here
Content-Type: application/json{
"username": "[email protected]",
"password": "your-password"
}Sample Code
curl -X POST https://sandbox-api.violet.io/v1/login \
-H "X-Violet-App-Id: your-app-id-here" \
-H "X-Violet-App-Secret: your-app-secret-here" \
-H "Content-Type: application/json" \
-d '{
"username": "[email protected]",
"password": "your-password"
}'async function authenticateWithViolet() {
try {
const response = await fetch('https://sandbox-api.violet.io/v1/login', {
method: 'POST',
headers: {
'X-Violet-App-Id': process.env.VIOLET_APP_ID,
'X-Violet-App-Secret': process.env.VIOLET_APP_SECRET,
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: process.env.VIOLET_USERNAME,
password: process.env.VIOLET_PASSWORD
})
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.message || 'Authentication failed');
}
const data = await response.json();
return {
authToken: data.token,
refreshToken: data.refresh_token,
expiresAt: new Date(data.expires_at)
};
} catch (error) {
console.error('Authentication failed:', error.message);
throw error;
}
}Expected Response
Last updated
Was this helpful?