Closed Jezternz closed 7 years ago
I ended up temporarily fixing this by modifying the "UpdateTokenAsync" method, to instead of "Update Access Token", now it will "Update Access token and retain previous Refresh Token"
protected async Task UpdateTokenAsync(CancellationToken cancellationToken = default(CancellationToken))
{
if (_token.ExpireDateTime > DateTime.Now)
return;
var nToken = await _oAuth2Provider.GenerateAccessTokenAsync(_token.RefreshToken, cancellationToken).ConfigureAwait(false);
_token = new Token(
nToken.AccessToken,
nToken.TokenType,
nToken.ExpiresIn,
_token.RefreshToken,
nToken.ExpireDateTime
);
}
Thanks for the lightning fast updates as usual!
I have been stepping through my code, and I noticed that after calling GetTokenAsync() the token becomes corrupted in that the refresh token dissapears on response (is set to null).
eg:
Examining your code I noticed the following:
GoogleClientBase.cs:33
GoogleOAuth2ProviderBase.cs:91
What I think is probably happening, is that the "ReceiveJson" response from google, does not include the original RefreshToken? So before we set our token to override previous one, we should pull out the refresh token and add it, something like eg:
It looks like we are overriding our "Refresh token without out of date Access token" with "No Refresh token, but up to date Access token", which of course causes problems down the track.