Forum Discussion
Send refresh token to backend
- Feb 23, 2023
I fixed this by implementing the https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow where the front end gets a specific kind of SSO/authorization token, and sends it to the backend, which exchanges it for a more permanent token.
It took a while to figure out how to request the SSO token in the front end, it turns out there are two ways to get it:
microsoftTeams.authentication.getAuthToken()
or
teamsFx.getCredential().getToken([]); // an empty scopes array
On the backend I use the "acquire on behalf of" method and pass in the auth/SSO token, and exchange it for a permanent access token. I use a TokenCache to store the refresh and access tokens for each user in the database.
I fixed this by implementing the https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow where the front end gets a specific kind of SSO/authorization token, and sends it to the backend, which exchanges it for a more permanent token.
It took a while to figure out how to request the SSO token in the front end, it turns out there are two ways to get it:
microsoftTeams.authentication.getAuthToken()
or
teamsFx.getCredential().getToken([]); // an empty scopes array
On the backend I use the "acquire on behalf of" method and pass in the auth/SSO token, and exchange it for a permanent access token. I use a TokenCache to store the refresh and access tokens for each user in the database.