node-imap icon indicating copy to clipboard operation
node-imap copied to clipboard

Authentication Failed on Sever, working on Localhost.

Open anandchapter247 opened this issue 5 years ago • 10 comments
trafficstars

I am implementing IMAP with outlook. Everything is working find on the local machine, but when I moved the code to server, it is returning authentication error.

Error: LOGIN failed. Account is blocked. Login to your account via a web browser to verify your identity.
0|plycoco-app  |     at Connection._resTagged (/var/www/html/plycoco/server/node_modules/imap/lib/Connection.js:1502:11)
0|plycoco-app  |     at Parser.<anonymous> (/var/www/html/plycoco/server/node_modules/imap/lib/Connection.js:194:10)
0|plycoco-app  |     at Parser.emit (events.js:223:5)
0|plycoco-app  |     at Parser._resTagged (/var/www/html/plycoco/server/node_modules/imap/lib/Parser.js:175:10)
0|plycoco-app  |     at Parser._parse (/var/www/html/plycoco/server/node_modules/imap/lib/Parser.js:139:16)
0|plycoco-app  |     at Parser._tryread (/var/www/html/plycoco/server/node_modules/imap/lib/Parser.js:82:15)
0|plycoco-app  |     at TLSSocket.Parser._cbReadable (/var/www/html/plycoco/server/node_modules/imap/lib/Parser.js:53:12)
0|plycoco-app  |     at TLSSocket.emit (events.js:223:5)
0|plycoco-app  |     at emitReadable_ (_stream_readable.js:576:12)
0|plycoco-app  |     at processTicksAndRejections (internal/process/task_queues.js:80:21)
0|plycoco-app  | Emitted 'error' event on Connection instance at:
0|plycoco-app  |     at reentry (/var/www/html/plycoco/server/node_modules/imap/lib/Connection.js:1610:12)
0|plycoco-app  |     at Connection.checkCaps (/var/www/html/plycoco/server/node_modules/imap/lib/Connection.js:1635:22)
0|plycoco-app  |     at Connection._resTagged (/var/www/html/plycoco/server/node_modules/imap/lib/Connection.js:1535:22)
0|plycoco-app  |     at Parser.<anonymous> (/var/www/html/plycoco/server/node_modules/imap/lib/Connection.js:194:10)
0|plycoco-app  |     [... lines matching original stack trace ...]
0|plycoco-app  |     at processTicksAndRejections (internal/process/task_queues.js:80:21) {
0|plycoco-app  |   type: 'no',
0|plycoco-app  |   textCode: undefined,
0|plycoco-app  |   source: 'authentication'
0|plycoco-app  | }

Is there anything I need to update in my Outlook account? If so, please suggest.

anandchapter247 avatar Mar 20 '20 13:03 anandchapter247

Did you try logging into your account in a web browser to verify your identity, like it says in the first line of the error message?

You'll probably need to use OAuth instead of password authentication to avoid security barriers like this one.

hallettj avatar Mar 20 '20 13:03 hallettj

Yes, I tried. And I don't need to add OAuth as I only have to get emails of a single account only. I am not sure why it is not working on the server but working locally. Is there anything I am missing?

anandchapter247 avatar Mar 23 '20 07:03 anandchapter247

Are you able to log in using the same set of credentials via the IMAP provider's webmail interface? Is two-factor authentication enabled on the account?

mscdex avatar Mar 23 '20 11:03 mscdex

Yes! I am able to log in and no, I don't have two-factor authentication enabled.

anandchapter247 avatar Mar 24 '20 08:03 anandchapter247

I don't know what else to suggest then, other than to contact the support folks for the server in question.

mscdex avatar Mar 24 '20 08:03 mscdex

Thanks!

anandchapter247 avatar Mar 30 '20 13:03 anandchapter247

i also facing same problems.

mnnitsarvesh-ai avatar Sep 21 '21 09:09 mnnitsarvesh-ai

Could anyone please help on the same issue mentioned above,

{ type: 'no', textCode: undefined, source: 'authentication', level: 'error' }

The above is the error message that i am getting, login username and password is also correct. I tried debugging this, got the below,


<= '* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+'
<= 'A0 OK CAPABILITY completed.'
=> 'A1 LOGIN "************@*****.com"             "**************"'
<= 'A1 NO LOGIN failed.'


[connection] Ended
[connection] Closed
[connection] Connected to host
<= '* OK The Microsoft Exchange IMAP4 service is ready. [TQBBAFgAUABSADAAMQAwADEAQwBBADAAMAAyADcALgBJAE4ARABQAFIARAAwADEALgBQAFIATwBEAC4ATwBVAFQATABPAE8ASwAuAEMATwBNAA==]'
=> 'A0 CAPABILITY'
<= '* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+'
<= 'A0 OK CAPABILITY completed.'
=> 'A1 LOGIN "************@*****.com"             "**************"'
<= 'A1 NO LOGIN failed.'

Please anyone help me to resolve this, i checked the complete world of stackoverflow, but nobody couldnt fix this. I appreciate if anyone has the solution.

export const imapConfig = { imap: { user: process.env.OUTLOOK_USER, password: '', host: process.env.OUTLOOK_HOST, port: Number(process.env.OUTLOOK_PORT || 993), tls: true, authTimeout: 25000, connTimeout: 30000, keepalive: true, secure: true, debug: console.log tlsOptions: { rejectUnauthorized: false servername: process.env.OUTLOOK_HOST host: process.env.OUTLOOK_HOST } } }

gsaravanakumar932 avatar May 19 '22 12:05 gsaravanakumar932

Did anyone manage to fix the issue? My Authentication has stopped working.

avblink avatar Nov 07 '22 07:11 avblink

I'm also facing the same issue. Did you find a fix @gsaravanakumar932?

henryp0p avatar Jan 04 '23 10:01 henryp0p