internal void ResetAccessToken() { _accessToken = null; }
internal async Task<Token> GetAccessToken() { if (CredentialType != CredentialType.ClientCredentials && CredentialType != CredentialType.ResourceOwner && CredentialType != CredentialType.RefreshToken || (_accessToken != null && _accessToken.Expiration >= DateTime.UtcNow.AddMinutes(-5))) { return _accessToken; } var helper = new WebHelper(this, _baseUrl); var response = await helper.PostForm(GetCredentialsDictionary(), Oauth2TokenPath, null, null, false); _accessToken = new Token { AccessToken = response.access_token.ToString(), Expiration = DateTime.UtcNow.Add(TimeSpan.FromSeconds((double) response.expires_in)), RefreshToken = response.refresh_token }; return _accessToken; }