Menu

Tree [8214fe] main /
 History

HTTPS access


File Date Author Commit
 .devcontainer 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 .vscode 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 .gitignore 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 README.md 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 imapQA.js 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 main.js 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 package-lock.json 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 package.json 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email
 token.js 2024-01-25 David Ljuba David Ljuba [8214fe] fetching outlook imap email

Read Me

Code example used to start

Best example to aquire authentication token using MSAL library and contanct IMAP Microsoft Outlook server:
https://learn.microsoft.com/en-us/answers/questions/875398/read-outlook-mails-via-imap-using-nodejs-and-oauth

MS Authentication Lib example for Node js app

Client id or Application id

Client id or Application id is clientId in msalConfig:

clientId: "91..."

Tenant Id or Directory ID

Every organisation or company that is renting cloud from Azure is tenant in Azure AD (Azure Active Directory has many, many tenants).
Tenenat Id is top most ID of your company in Azure.

This id is used as authority in msalConfig:

authority: "https://login.microsoftonline.com/<Directory (tenant) ID>",

Client secret

Secret is as clientSecret in msalConfig:

clientSecret: "bX-..."

Check this link to create it correctly

Scopes

You must use https://outlook.office365.com/.default in the scope property in the body payload for the access token request.

Keep up to date

# check outdated dependencies:
npm outdated
# response may look like:
Package                  Current   Wanted   Latest  Location                              Depended by
@azure/msal-node          1.17.0   1.17.3   1.17.3  node_modules/@azure/
npm notice 
npm notice New minor version of npm available! 9.5.1 -> 9.7.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.7.1
npm notice Run npm install -g npm@9.7.1 to update!
npm notice
# change versions in package.json or run:
npm update --save

Example output

/usr/local/bin/node ./main.js
Starting
Fetching OAuth2 token - start
Fetching OAuth2 token - done
Fetching link - start
Fetching link - done
link -  
Fetching link - start
Fetching link - done
Ending
required --- To: referralcode377@test22.bla.rs
received --- To: referralcode377@test22.bla.rs
required --- To: referralcode377@test22.bla.rs
-- 😺 -- We got required verification email! Required --- To: referralcode377@test22.bla.rs--
(#3295) Finished email
Done fetching all messages!
statusCode|method|url - 302|GET|https://u25715676.ct.sendgrid.net/ls/click?upn=wQTa-2FoGgqaNkrcyur......w0fiOTBliyrNM-2BlJd
token - 96c5112c-a9f8-4cbb-bbf0-aa9c83e13754
link - https://example.com/verifyEmail
statusCode|method|url - 404|POST|https://example.com/verifyEmail?token=96c5112c-a9f8-4cbb-bbf0-aa9c83e13754
Connection ended
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.