automatic token refresh, initial stage
This commit is contained in:
21
backend/helpers/database.js
Normal file
21
backend/helpers/database.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const config = require('../config');
|
||||
|
||||
var db = null;
|
||||
|
||||
|
||||
module.exports = {
|
||||
initModule : function(databaseObject){
|
||||
db=databaseObject;
|
||||
},
|
||||
|
||||
loadTokens : function(){
|
||||
db.collection('token_list').findOne().then(tokens=>{
|
||||
config.TOKEN = tokens.access_token;
|
||||
config.REFRESH_TOKEN = tokens.refresh_token;
|
||||
config.TOKEN_EXPIRES_IN = tokens.expires_in;
|
||||
console.log("Tokens loaded");
|
||||
}).catch(e=>{
|
||||
console.log("Error loading tokens");
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user