Hello @jhirono ,
I Understand your application is unable to obtain a refresh token when authenticating with Microsoft Graph API using MSAL Node.js. The refresh token is not included in the token response.As your application is unable to obtain a refresh token when authenticating with Microsoft Graph API using MSAL Node.js. Despite explicitly requesting the offline_access scope and forcing consent, the refresh token is not included in the token response.
MSAL Node, like other MSAL libraries, does not expose refresh tokens for security reasons. Instead, MSAL handles the token refresh process automatically.
If you need to retrieve the refresh token, it is not directly included in the response. Instead, it is stored in the MSAL token cache, which keeps track of tokens for future use. MSAL manages this cache internally, and you can access it when needed using the getTokenCache()
method.
To retrieve the refresh tokens and call the User Info Endpoint, refer to the modifications outlined in the document here: StackOverflow link.
As for implementing persistent authentication for your desktop application, I recommend using a conditional access policy with a sign-in frequency that requires periodic authentication. This approach will ensure users can maintain continuous access to the application..
Follow the document for detailed explanation and Implementation of conditional Access policy and Sign in frequency.
For Additional Information: MSAL Refresh Token, Refresh Token Grant
Hope this Helps Let me know if you any additional Queries Happy to assist you further.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.