I am implementing google sign-in in my Nuxtjs project and response_type:'code' is not working either in ux_mode:'popup' nor ux_mode:'redirect' in both modes when I check the url reponse_type is equal to permission not code even though I have specified it should be code, in popup mode the popup closes and return popup closed by user error and in redirect mode if I change response_type to code in the url then everything works well so it just needs to be code for everything to work.
here is my google sign in code:
<button role="button" class="btn-social" @click.stop="signInWithGoogle()">
<img src="~/assets/icons/google.svg" alt="" class="lg:block hidden">
With Google
</button>
the method:
signInWithGoogle() {
gapi.auth2.getAuthInstance().signIn();
}
and the initialization:
gapi.load('client:auth2', () => {// callback function});
gapi.client.init({
clientId: process.env.GOOGLE_CLIENT_ID,
discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest'],
scope: 'profile email',
ux_mode: 'popup',
redirect_uri: 'http://lvh.me:8000/googleRedirect',
response_type: 'code',
access_type: 'offline',
include_granted_scopes: true,
prompt: 'select_account',
});
})
note: I have added URL and redirect URLs in my google console so there is no redirect URI mismatch error.