How to implement Gmail api using ionic 5

Hi Team,

I am developing a project to read all Gmail inbox mails through my ionic app.

I created Oauth client id and Api key using “google console platform”

and i calling this function to init the google

const scopes = [‘’,
'’].join(’ ');
const payload = new Promise((resolve) => {
gapi.load(‘auth2’, resolve);
return payload.then(async () => {
await gapi.auth2
client_id: this.clientId,
access_type: ‘offline’,
include_granted_scopes: true,
.then(auth => {
this.gapiSetup = true;
this.authInstance = auth;
}).catch(e => {
console.log(‘Error initiating Google auth’);
I am getting below error, i hav
gapi.auth2.ExternallyVisibleError: gapi.auth2 has been initialized with different options. Consider calling gapi.auth2.getAuthInstance() instead of gapi.auth2.init().

But the google docs mentioned init function only for to get the details

How to resolve this error?

Thanks in advance

1 Like