Gmail API error

16 views
Skip to first unread message

Ramji BH

unread,
Dec 14, 2020, 10:41:58 AM12/14/20
to Angular and AngularJS discussion
Hi Team,

I am using Gmail api in Angular 9, After authenticate, when i send email first time its not sending the email, once i refresh the page then only the email sending correctly.

My code snippet, if anything wrong please reply. Thanks in Advance

gapi.load('client:auth2', () => {gapi.client.load('gmail', 'v1', () => { gapi.client.setToken({ access_token: localStorage.getItem('accessToken') }); gapi.client.init({ Key: this.apiKey, discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest'], client_id: this.clientId, immediate: true, scope:'https://www.googleapis.com/auth/gmail.send' }).then(res => { return gapi.client.gmail.users.messages.send({ userId: this.useremail, resource: { raw:btoa(message).replace(/\+/g, '-').replace(/\//g, '_'), } }).then(res => { var returnbody=JSON.parse(res.body); }); }) }); });  

Regards,
Ramji
Reply all
Reply to author
Forward
0 new messages