mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Fix access token expires issue (#1554)
This commit is contained in:
parent
1cbe0b7b9f
commit
033e058745
@ -9,8 +9,9 @@ export default function fetchToken(clientId, code) {
|
||||
body: data,
|
||||
}).then((resp) => {
|
||||
if (!resp.ok) throw new Error('Unable to fetch tokens');
|
||||
const tokens = resp.json();
|
||||
tokens.expires = (tokens.expires_in * 1000) + Date.now();
|
||||
return tokens;
|
||||
return resp.json().then((tokens) => {
|
||||
tokens.expires = (tokens.expires_in * 1000) + Date.now();
|
||||
return tokens;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -9,8 +9,9 @@ export default function refreshAccessToken(clientId, refreshToken) {
|
||||
body: data,
|
||||
}).then((resp) => {
|
||||
if (!resp.ok) throw new Error('Unable to fetch tokens');
|
||||
const tokens = resp.json();
|
||||
tokens.expires = (tokens.expires_in * 1000) + Date.now();
|
||||
return tokens;
|
||||
return resp.json().then((tokens) => {
|
||||
tokens.expires = (tokens.expires_in * 1000) + Date.now();
|
||||
return tokens;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ function redirectLogin() {
|
||||
|
||||
window.refreshToken = () =>
|
||||
refreshToken_(clientId(), window.tokens.refresh_token).then((accessTokenResp) => {
|
||||
window.tokens.access_token = accessTokenResp.access_token;
|
||||
window.tokens = Object.assign({}, window.tokens, accessTokenResp);
|
||||
localStorage.tokens = JSON.stringify(window.tokens);
|
||||
return {
|
||||
access_token: accessTokenResp.access_token,
|
||||
|
Loading…
x
Reference in New Issue
Block a user