Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmail Service Account dont want authenticate #2860

Closed
NonozgYtb opened this issue Dec 12, 2021 · 3 comments
Closed

Gmail Service Account dont want authenticate #2860

NonozgYtb opened this issue Dec 12, 2021 · 3 comments

Comments

@NonozgYtb
Copy link

Hi everyone,
After several long hours, I still cannot use my service account for Gmail. I'm a Google Workspace customer, but whether it's through JWT, OAuth, or other things (some of which the current version no longer supports), nothing helps and I get just errors. I don't really know what to do to be able to access information (via an OAuth client for my account only its walking) on ​​the gmail accounts of my members.
Can I have a (actual) solution ?
Thanks a lot.
PS: sorry for the text pad but it's late and I'm exhausted and quite frustrated with this problem

@NonozgYtb
Copy link
Author

Hi,
After a lot of research, I found a solution that works (I use the promises):

const credentials = require("./credentials.json") // File downloaded with the Service Account Keys
const getGmailAuth  = async ()=>{
       const auth = (new google.auth.JWT(
            credentials.global.client_email,
            null,
            credentials.global.private_key,
            GMAILSCOPES,
            person
        ))
        await (new Promise((resolve, reject) => {
            auth.authorize((err, tokens) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(tokens);
                }
            });
        }))
        return (auth);
}

Good bye !

@frozen-a-b
Copy link

Hi @NonozgYtb ,

I think I ran into a similar issue

What is person in your code?

@NonozgYtb
Copy link
Author

NonozgYtb commented Jan 28, 2022

Hi @NonozgYtb ,

I think I ran into a similar issue

What is person in your code?

person is a string with an email like :

const person = "firstname.name@mydomain.com";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants