I want to send an email from the Google account currently logged, so I'm trying to send mail through XOAuth2 option.
I'm setting these parameters:
XOAuth2: {
user: <application's email account which I login using oauth> (not the account i'm trying to send the mail),
clientId: <Client ID for web application>,
clientSecret: <Client secret from web application>,
refreshToken: <the one I get in OAuth 2.0 Playground>
}
Also I'm using hello.js for authenticating with OAuth2.
Is this configuration correct?
Thanks in advance!
unauthorized_client might happen when clientId and clientSecret do not match
It says 'Username and Password not accepted. [...]"
I use clientId, clientSecret and user (email address) from console.developers.google.com.
XOAuth2 parameters change depending on who is sending the email or those parameters are from Google App owner?
I already added https://mail.google.com/ scope on Google's OAuth 2.0 Playground
Any chance to send an email using this library, without requiring the user to type his password every time?
Check the following things :-
XOAuth2: {
user: "[email protected]", // Your gmail address.
pass: "XXXXXXXXXXXXXXX", // Not @developer.gserviceaccount.com
clientId: "XXXXXXXXXXXXX",
clientSecret: "XXXXXXXXXXXXX",
refreshToken: "XXXXXXXXXXXXX"
}
For anyone having "unauthorized_client" issues whilst the following apply:
I finally solved it following the documentation here: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority
In essence going to
https://admin.google.com/yourgsuitedomain.com/ManageOauthClients
Adding a client id (from service account) and scope: https://mail.google.com/ (final slash important)
Emails started working after that.
Most helpful comment
For anyone having "unauthorized_client" issues whilst the following apply:
I finally solved it following the documentation here: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority
In essence going to
https://admin.google.com/yourgsuitedomain.com/ManageOauthClients
Adding a client id (from service account) and scope: https://mail.google.com/ (final slash important)
Emails started working after that.