question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with XOAUTH2

See original GitHub issue

I am trying to use XOAUTH2 to connect to google IMAP, I updated the Connections constructor method by allowing set config.xoauth2.

Could you help check why this happened, and how to fix it?

<= '* OK Gimap ready for requests from 50.156.50.203 qk7if1705226pac.117'
=> 'A0 CAPABILITY'
<= '* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2'
<= 'A0 OK Thats all she wrote! qk7if1705226pac.117'
=> 'A1 AUTHENTICATE XOAUTH2 xxxx'
<= '+ eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ=='
<= 'A1 NO Invalid SASL argument. qk7if1705226pac.117'
{ [Error: {"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}] textCode: undefined, source: 'authentication' }

My imap options:

{ host: 'imap.gmail.com',
  port: 993,
  tls: true,
  user: 'xxxxxxxxxxx@gmail.com',
  password: '',
  xoauth2: 'xxxx',
  tlsOptions: { rejectUnauthorized: false },
  debug: console.log
}

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
viktorjanssoncommented, Feb 6, 2017

Make sure your xoauth2 string is formatted like this

new Imap({xoauth2:btoa("user="+USER+"\x01auth=Bearer "+TOKEN+"\x01\x01"), ... })

0reactions
fhackenbcommented, Aug 9, 2018

Thanks for the prompt reply! I figured out that the issue was with my scopes when authorizing with OAuth2. I needed to add “https://mail.google.com/” to my list of scopes

Read more comments on GitHub >

github_iconTop Results From Across the Web

SMTP XOAUTH2 Authentication Problem for GoDaddy accounts
SMTP XOAUTH2 Authentication Problem for GoDaddy accounts. Dear Sir/Madam,. We are following Microsoft authentication instructions to connect ...
Read more >
OAuth 2.0 Mechanism | Gmail - Google Developers
This document defines the SASL XOAUTH2 mechanism for use with the IMAP AUTHENTICATE , POP AUTH , and SMTP AUTH commands. This mechanism...
Read more >
PHPMailer authentication issue xoauth2 - Stack Overflow
Auth method requested: XOAUTH2 Auth methods available on the server: PLAIN,LOGIN SMTP Error: Could not authenticate. Now my host isn't ...
Read more >
MS Exchange - IMAP-XOAuth2 authentication fails - GitLab
The OAuth2 client obtains a valid token with proper scopes - but it doesn't speak IMAP-XOAuth2 correctly. The problem is in the OAuth2...
Read more >
oauth2 - Go Packages
oauth2 package contains a client implementation for OAuth 2.0 spec. Installation. go get golang.org/x/oauth2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found