Connect my web application with Microsoft account

Suhaib Saleh 11 Reputation points
2023-01-15T06:11:57.8133333+00:00

Hi everyone

I am creating a web application and I need to do the following

Allow the user to connect his account on my web app with his Microsoft account, so when creates a meeting in my web app it will automatically create a meeting in his calendar

Similar to the outlook calendar app on slack.

I was able to authenticate the account and get the access token, and use it in the graph API to create the meeting

But this token expires after 1 hour and I need this process to be permanent, and the refresh token requires action from the user himself

I need the user to connect his account once, and then he doesn't need to do anything

Is there anyway to do that?

Thanks

Microsoft 365 and Office Development Office JavaScript API
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 6,081 Reputation points
    2023-01-24T00:30:49.0733333+00:00

    Hi @Suhaib Saleh

    TokenLifetimePolicy can help you in this scenario. As per this table the maximum value AccessTokenLifetime is 1day.
    222709-table-3.png

    Please refer to the above documentation for more details.

    You can also refer to refresh token. The default lifetime for the refresh tokens is 24 hours for single page apps and 90 days for all other scenarios. So, if you want to get refresh token the only way is to use auth code flow or ROPC flow.

    Please go through these relevant documentation also.
    Configurable token lifetimes in the Microsoft identity platform (preview)
    Configure token lifetime policies (preview)

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.