Persist new refresh token
This commit is contained in:
parent
7ecb7f22e3
commit
3cf00043b1
1 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import prisma from "./prisma";
|
||||||
|
|
||||||
function handleErrorsJson(response) {
|
function handleErrorsJson(response) {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
response.json().then(console.log);
|
response.json().then(console.log);
|
||||||
|
@ -31,7 +33,16 @@ const zoomAuth = (credential) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(handleErrorsJson)
|
.then(handleErrorsJson)
|
||||||
.then((responseBody) => {
|
.then(async (responseBody) => {
|
||||||
|
// Store new tokens in database.
|
||||||
|
await prisma.credential.update({
|
||||||
|
where: {
|
||||||
|
id: credential.id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
key: responseBody
|
||||||
|
}
|
||||||
|
});
|
||||||
credential.key.access_token = responseBody.access_token;
|
credential.key.access_token = responseBody.access_token;
|
||||||
credential.key.expires_in = Math.round((+(new Date()) / 1000) + responseBody.expires_in);
|
credential.key.expires_in = Math.round((+(new Date()) / 1000) + responseBody.expires_in);
|
||||||
return credential.key.access_token;
|
return credential.key.access_token;
|
||||||
|
|
Loading…
Reference in a new issue