コード例 #1
0
        /// <summary>
        /// Refresh the current credentials if a valid refresh token is present.
        /// </summary>
        /// <returns>The refresh.</returns>
        public async Task Refresh()
        {
            if (RefreshToken == null)
            {
                throw new Exception("currentCredentials did not have a refresh token");
            }

            TokenLifecycleManager tlcm          = new TokenLifecycleManager();
            TokenResponse         tokenResponse = await tlcm.RefreshTokenAsync(AuthState.TokenRefreshRequest()).ConfigureAwait(false);

            AuthState.Update(tokenResponse, null);
        }
コード例 #2
0
        private async Task <AuthState> PerformRefresh(AuthState authState)
        {
            MicroLogger.LogDebug(nameof(PerformRefresh));

            var request = authState.TokenRefreshRequest();

            try
            {
                var tokenResponse = await AuthorizationService.PerformTokenRequestAsync(request);

                MicroLogger.LogDebug($"Received token response with accessToken: {tokenResponse.AccessToken}");

                authState.Update(tokenResponse, null);
            }
            catch (NSErrorException ex)
            {
                authState.Update(ex.Error);

                MicroLogger.LogError($"Token exchange error: {ex}");
            }
            return(authState);
        }