Using xoauth2 authentication failed
See original GitHub issueHi, I am using xoauth2 to connect to imap and I’m getting this error:
`[09:50:28.806] [LOG] [connection] Connected to host
[09:50:28.873] [LOG] <= '* OK Gimap ready for requests from 31.154.25.42 q4mb701
07656lfe'
[09:50:28.881] [LOG] => 'A0 CAPABILITY'
[09:50:29.067] [LOG] <= '* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID
XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIE
NTTOKEN AUTH=OAUTHBEARER AUTH=XOAUTH'
[09:50:29.069] [LOG] <= 'A0 OK Thats all she wrote! q4mb70107656lfe'
[09:50:29.073] [LOG] => 'A1 AUTHENTICATE XOAUTH2 ******************************************
****************************************************************************************************************************
********************************************************************************='
[09:50:29.374] [LOG] <= '+ eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2Nvc
GUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ=='
[09:50:29.377] [LOG] => '\r\n'
[09:50:29.534] [LOG] <= 'A1 NO [AUTHENTICATIONFAILED] Invalid credentials (Failu
re)'
[09:50:29.537] [ERROR] ERROR Imap:Error: Invalid credentials (Failure)
[09:50:29.755] [LOG] [connection] Ended
[09:50:29.756] [LOG] Imap: Connection ended
[09:50:29.758] [LOG] [connection] Closed`
here is my connection code :
`this.setImap = function(connParams) {
//----------------------------------------------
console.log(connParams);
xoauth2gen = xoauth2.createXOAuth2Generator({
user: connParams.user",
clientId: configAuth.googleAuth.clientID,
clientSecret: configAuth.googleAuth.clientSecret,
refreshToken: connParams.refresh_token,
accessToken: connParams.access_token,
customPayload: {
"access_type": "offline"
}
});
xoauth2gen.getToken(function(err, token) {
if (err) {
return console.log(err);
}
console.log("AUTH XOAUTH2 " + token);
connParams.xoauth2 = token;
});
connParams = {
id: 13,
user: connParams.user,
xoauth2: connParams.xoauth2,
host: 'imap.gmail.com',
port: 993,
tls: 1,
debug: console.log
}
//-------------------------------------------
connParams.tlsOptions = {
rejectUnauthorized: false
};
console.log(connParams);
self.imap = new Imap(connParams);
this.imap.once('ready', function() {
console.log('Imap: ready');
self.openInbox();
});
this.imap.once('error', function(err) {
console.error("ERROR Imap:" + err);
});
this.imap.once('end', function() {
console.log('Imap: Connection ended');
});
};
Checked a million time the details 😦
here is the scope I’m using :
scope: ['profile', "https://mail.google.com/" ]
I would appreciate any help, Thanks!!
Issue Analytics
- State:
- Created 8 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Office 365 XOAUTH2 for IMAP and SMTP Authentication fails
I obtained the first token for graph scopes using authorization code, received after the user consent step, and the second one for outlook ......
Read more >Windows Live Mail - XOAUTH2 authentication failed
2 days ago, I was suddenly unable to access Hotmail using Windows Live Mail with IMAP. What change did Microsoft make to its...
Read more >Windows Live Mail - XOAUTH2 authentication failed
1 Answer 1 · Right-click on the account name in the folder pane, and select "Properties". . · On the "Servers" tab: a....
Read more >Outlook.com: IMAP-XOAUTH2 login fails – some mail clients ...
XOAUTH2 is an authentication method used as the default for logging into IMAP mailboxes in GMail, among others. According to this post, ...
Read more >MS Exchange - IMAP-XOAuth2 authentication fails - GitLab
Current behavior. The IMAP server responds with NO AUTHENTICATE failed. and * BAD Command Error. 12. In the GUI, it appears as ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ShaharLahav I’m currently getting the same exact sequence of debug statements and the error that you had at the beginning of this thread. I’m using the xoauth2 generator library as you are with getToken… and creating an imap instance as you are too. Could you describe in a little more detail what you did to get that connection working for me? Maybe post the xoauth2generator/token retrieval and imap configuration code that worked for you?
@spyeadon you figure this out either?