Answer the question
In order to leave comments, you need to log in
How to implement sign out through gapi?
I am writing Vue js app.
In the index html file, I included the following in the head tag:
<meta name="google-signin-client_id" content="<my_client_id>.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
template: `
...
<div id="google-signin-button"></div>
...
`
methods: {
...
onSignIn (user) {
const profile = user.getBasicProfile();
this.login(profile);
}
...
}
mounted() {
...
gapi.signin2.render('google-signin-button', {
onsuccess: this.onSignIn
})
...
},
logout: function () {
var self = this;
if(confirm("Вы действительно хотите выйти?")) {
const auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('user signed out');
self.$store.dispatch('authentication/logout')
.then(() => {
self.$router.push('/login')
})
});
}
},
Answer the question
In order to leave comments, you need to log in
Ok, I forgot to start the webserver. After I used the last mentioned link, got the auth2 global variable and used it for signOut. Done.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question