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

XOAuth2 returns "unauthorized_client" #266

Closed
maggialejandro opened this issue May 12, 2014 · 5 comments
Closed

XOAuth2 returns "unauthorized_client" #266

maggialejandro opened this issue May 12, 2014 · 5 comments

Comments

@maggialejandro
Copy link

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!

@andris9
Copy link
Member

andris9 commented May 12, 2014

unauthorized_client might happen when clientId and clientSecret do not match

@maggialejandro
Copy link
Author

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

@maggialejandro
Copy link
Author

Any chance to send an email using this library, without requiring the user to type his password every time?

@andris9 andris9 closed this as completed Jul 30, 2014
@AnupKumarPanwar
Copy link

AnupKumarPanwar commented Oct 25, 2016

Check the following things :-

  1. The Redirect URI is set to "https://developers.google.com/oauthplayground" in your Google Developer Console Project.
  2. Enter the values of "pass" parameters too. Something like
    XOAuth2: { user: "username@gmail.com", // Your gmail address. pass: "XXXXXXXXXXXXXXX", // Not @developer.gserviceaccount.com clientId: "XXXXXXXXXXXXX", clientSecret: "XXXXXXXXXXXXX", refreshToken: "XXXXXXXXXXXXX" }

Check This Example

@AdamCraven
Copy link

AdamCraven commented Oct 16, 2019

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.

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

4 participants