I was looking here about refresh tokens.
I have this code to get a access token:
if(bPromptUser)
{
_AuthResult = await PublicClientApp.AcquireTokenAsync(_scopes); //Opens Microsoft Login Screen
using (RegistryKey key = Registry.CurrentUser.CreateSubKey(keyName))
{
key.OpenSubKey(keyName, true);
key.SetValue("Status", _AuthResult.AccessToken);
key.SetValue("Expire", _AuthResult.ExpiresOn.ToLocalTime().ToString());
key.Close();
token = _AuthResult.AccessToken;
}
// Append the access token to the request.
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", token);
}
But my _AuthResult
doesn't actually have a RefreskToken
in the list. Is this because I am using v1 of Microsoft Graph?
Update
According to the documentation the scope suggested in the answer is on by default?
Microsoft provide sample code for TokenCacheHelper.
Add that to your project and provide an instance of it. Then, set the path. Like this:
That is all you need to do. The cache file contains all the token details, including the refresh token.
More details are in the conversation here. In part: