Get started with gmail-js CDN
MIT licensed
Gmail-js: Read-only Gmail access for web apps via lightweight library.
Tags:- gmail
- gmail api
- gmail.js
- gmail extension
- gmail chrome extension
Stable version
Copied!
How to start using gmail-js CDN
// Include the Gmail API script from the CDN
const gmailScript = document.createElement('script');
gmailScript.src = 'https://cdn.cdnhub.io/gmail-js/1.1.14/gmail.min.js';
document.head.appendChild(gmailScript);
// Wait for the script to load before initializing the library
gmailScript.onload = () => {
// Initialize the Gmail API client
const gmail = new GmailApp();
// Set up the authorization scopes and callback function
gmail.setUser('me'); // Replace 'me' with the user email address
gmail.useDefaultClient();
gmail.authorize((auth) => {
if (auth.error) {
console.log('Error:', auth.error);
return;
}
// Perform actions with the authorized Gmail API client
const thread = gmail.users.threads.list('me').then((threads) => {
const firstThread = threads.threads[0];
return gmail.users.messages.list(firstThread.id, {q: 'is:inbox'});
});
thread.then((messages) => {
const firstMessage = messages.messages[0];
console.log('First message subject:', firstMessage.snippet);
});
});
};
Copied!
Copied!
Copied!
All versions
0.2.2
0.4.0
0.4.1
0.5.0
0.5.1
0.5.2
0.5.3
0.6.0
0.6.1
0.6.10
0.6.11
0.6.12
0.6.13
0.6.14
0.6.2
0.6.3
0.6.4
0.6.5
0.6.6
0.6.7
0.6.8
0.7.0
0.7.1
0.7.2
0.7.3
0.7.4
0.7.5
0.7.6
0.7.7
0.8.0
0.8.1
0.8.2
0.9.0
0.9.1
0.9.2
0.9.3
0.9.4
0.9.5
0.9.6
0.9.7
0.9.8
0.9.9
1.0.0
1.0.1
1.0.10
1.0.11
1.0.12
1.0.13
1.0.14
1.0.15
1.0.16
1.0.17
1.0.18
1.0.19
1.0.2
1.0.20
1.0.21
1.0.22
1.0.23
1.0.24
1.0.3
1.0.4
1.0.5
1.0.6
1.0.7
1.0.8
1.0.9
1.1.0
1.1.1
1.1.10
1.1.11
1.1.12
1.1.13
1.1.14
*** 1.1.15
1.1.2
1.1.3
1.1.4
1.1.5
1.1.6
1.1.7
1.1.8
1.1.9