/// <summary> /// Uses a Refresh Token to obtain a new Access Token and stores it in the Token Manager. /// </summary> /// <returns>If successful, returns the new Access Token as a string. Otherwise...</returns> /// private async Task <string> GetAndStoreApiAccessTokens() { TokenManager.ClearAccessTokens(); var disco = await GetDiscoveryDocumentAsync(_identityServerUrl); var request = MakeAccountsApiRefreshTokenRequest(disco.TokenEndpoint, TokenManager.GetAccessTokens().RefreshToken); var response = await RequestRefreshTokenAsync(request); // TODO: handle failure. TokenManager.SetAccessTokens(response.AccessToken, response.RefreshToken); return(response.AccessToken); }