Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
method: 'POST',
credentials: 'same-origin',
body: formData
});
if (!resp.ok) {
throw resp.status === 400 /* auth invalid */ ||
resp.status === 403 /* user not active */
? ERR_INVALID_AUTH
: new Error('Unable to fetch tokens');
}
const tokens: AuthData = await resp.json();
tokens.hassUrl = hassUrl;
tokens.clientId = clientId;
tokens.expires = genExpires(tokens.expires_in);
return tokens;
}