mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-24 11:06:35 +00:00

* Use authorize page if auth provider * Add webcomponent polyfill * More fixes * ES5 fix * Lint * Use redirect_uri * upgrade uglify to fix tests? * Update browsers used for testing
16 lines
416 B
JavaScript
16 lines
416 B
JavaScript
export default function fetchToken(clientId, code) {
|
|
const data = new FormData();
|
|
data.append('grant_type', 'authorization_code');
|
|
data.append('code', code);
|
|
return fetch('/auth/token', {
|
|
method: 'POST',
|
|
headers: {
|
|
authorization: `Basic ${btoa(clientId)}`
|
|
},
|
|
body: data,
|
|
}).then((resp) => {
|
|
if (!resp.ok) throw new Error('Unable to fetch tokens');
|
|
return resp.json();
|
|
});
|
|
}
|