I am currently working on my apps backup options. One option is to store a backup file to the users google drive. I am using VUE-GAPI wrapper. Right now I can successfully log the user in and connect to google drive to get a list of backup files.
What I am having a problem with is keeping the user logged in when the app is closed and then re-launched so that it automatically re connects to the users google drive.
I would like to know how that can be achieved with the google API.
I can get the users google Id and access token from when they login. I was thinking of saving that to the backend database and then on launch of my app process the information to re establish the authenticated link to the users drive. But I am unsure where to use this information for re authentication or if it is even possible to use that information.
this is what I have for my login
login() {
window.gapi.auth2.getAuthInstance().signIn({
scope: "https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive.metadata"
}).then(() => {
console.log('successfully authenticated');
this.authenticated = true;
this.userData = this.$gapi.getUserData();
this.$gapi.refreshToken
console.log(this.userData);
})
.catch((err) => {
console.error("Login call failed: %s", err.message);
});
},
Any insight on this issue would be helpful or even an alternate solution to get this done would be great.