Raymond Mlambo
Raymond Mlambo

Reputation: 83

How to automate outlook api calls for mail read

I have an app in NodeJS which calls the outlook api and reads a user's mails. I'm connecting this to a MySQL db where I'm storing specific email replies.The app is working perfectly. My problem is that I have to sign-in every hour to refresh the access token. I need a way of calling the outlook api, returning the emails, store them in a db, and then expose them through an API. And I wanna automate this outlook api call through a cron job. Does anyone have any ideas on how I can accomplish this?

Upvotes: 0

Views: 1116

Answers (1)

Yogesh
Yogesh

Reputation: 2228

What I believe you are looking for is App-only access a.k.a access without a user. More on this below.

https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_service

In addition, you get a refresh token along with the user consented access token. You can then refresh the access token periodically using the refresh token. More on this below:

https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code#refresh-the-access-token

Upvotes: 1

Related Questions