How to obtain a refresh token for Entra SSO in a bot application

Abhijeet Gupta 0 Reputation points
2025-04-18T13:36:40.1633333+00:00

I am using a bot to communicate with a backend service and implementing Entra SSO for user authentication. After user consent for accessing their personal information, the bot receives an access token that is valid for 1 hour.

What is the process for obtaining a refresh token that can be used to renew the access token for future uses?

Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,906 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prasad-MSFT 8,876 Reputation points Microsoft External Staff Moderator
    2025-04-21T06:11:49.1533333+00:00

    To obtain a refresh token and use it to renew the access token for your bot implementing Entra Single Sign-On (SSO), you will need to follow the OAuth 2.0 flow.

    1. After user consent and successful authentication, besides the access token, you should receive a refresh token, which you can use to renew the access token later.
    2. Ensure that you securely store the refresh token. It's sensitive data and should be kept in a secure storage solution, like Azure Key Vault.
    3. When the access token expires, you can use the refresh token to acquire a new access token. This involves making a request to the authorization server.

    Ref: https://learn.microsoft.com/en-us/entra/identity-platform/security-tokens

    https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/authentication/bot-sso-overview

    https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow

    Thanks, 

    Prasad Das

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.

    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.