guruahn / vue-google-oauth2

🔌 Handling Google sign-in and sign-out for Vue.js applications
MIT License
184 stars 55 forks source link

Requesting additional scopes #42

Closed nastykeller closed 4 years ago

nastykeller commented 4 years ago

Hey! How i can provide additional scopes after user sign in? Smth like this https://developers.google.com/identity/sign-in/web/incremental-auth#step_2_request_additional_scopes

const option = new gapi.auth2.SigninOptionsBuilder(); option.setScope('email https://www.googleapis.com/auth/drive')

In my app i need split auth logic and request permission for calendar. Thanks

guruahn commented 4 years ago

@nastykeller yes, you can provide additional scopes.

const option = new window.gapi.auth2.SigninOptionsBuilder();
option.setScope("email https://www.googleapis.com/auth/drive");
const googleUser = this.$gAuth.GoogleAuth.currentUser.get();
try {
    await googleUser.grant(option);
    console.log("success");
} catch (error) {
    console.error(error);
}

We will update the sample code here soon.