Exemple #1
0
        /// <summary>
        /// RefreshTokeAsync call
        /// </summary>
        /// <param name="cancellationToken">cancellationToken</param>
        /// <returns>Task of bool</returns>
        private async Task <bool> RefreshTokensAsync(CancellationToken cancellationToken)
        {
            var refreshToken = RefreshToken;

            if (string.IsNullOrEmpty(refreshToken))
            {
                return(false);
            }

            if (await _lock.WaitAsync(_lockTimeout, cancellationToken).ConfigureAwait(false))
            {
                try
                {
                    var response = await _tokenClient.RequestRefreshTokenAsync(refreshToken, cancellationToken : cancellationToken).ConfigureAwait(false);

                    if (!response.IsError)
                    {
                        _accessToken  = response.AccessToken;
                        _refreshToken = response.RefreshToken;

                        return(true);
                    }
                }
                finally
                {
                    _lock.Release();
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Refreshes access token to get new access token by manually passing token url
        /// </summary>
        ///  <param name="tokenEndpoint"></param>
        /// <param name="refreshToken"></param>
        /// <param name="extra"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <TokenResponse> RefreshTokenAsync(string tokenEndpoint, string refreshToken, object extra = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(tokenEndpoint))
            {
                AdvancedLogger.Log("RefreshToken Endpoint is empty.");
                return(new TokenResponse(HttpStatusCode.InternalServerError, "RefreshToken Endpoint is empty."));
            }

            AdvancedLoggerEnabled = true;
            //Set internal property to track only informational -intuit_tid based logs
            if (EnableAdvancedLoggerInfoMode == true)
            {
                ShowInfoLogs = true;
            }

            if (this.CustomLogger != null)
            {
                //Use custom logger
                AdvancedLogger = LogHelper.GetAdvancedLoggingCustom(this.CustomLogger);
            }
            else
            {
                //Intialize Logger
                AdvancedLogger = LogHelper.GetAdvancedLogging(enableSerilogRequestResponseLoggingForDebug: this.EnableSerilogRequestResponseLoggingForDebug, enableSerilogRequestResponseLoggingForTrace: this.EnableSerilogRequestResponseLoggingForTrace, enableSerilogRequestResponseLoggingForConsole: this.EnableSerilogRequestResponseLoggingForConsole, enableSerilogRequestResponseLoggingForFile: this.EnableSerilogRequestResponseLoggingForFile, serviceRequestLoggingLocationForFile: this.ServiceRequestLoggingLocationForFile);
            }

            var tokenClient = new TokenClient(tokenEndpoint, ClientID, ClientSecret);

            return(await tokenClient.RequestRefreshTokenAsync(refreshToken, cancellationToken).ConfigureAwait(false));
        }
Exemple #3
0
        /// <summary>
        /// Refreshes access token to get new access token
        /// </summary>
        /// <param name="refreshToken"></param>
        /// <param name="extra"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <TokenResponse> RefreshTokenAsync(string refreshToken, object extra = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            //Intialize Logger
            AdvancedLogger = LogHelper.GetAdvancedLogging(enableSerilogRequestResponseLoggingForDebug: this.EnableSerilogRequestResponseLoggingForDebug, enableSerilogRequestResponseLoggingForTrace: this.EnableSerilogRequestResponseLoggingForTrace, enableSerilogRequestResponseLoggingForConsole: this.EnableSerilogRequestResponseLoggingForConsole, enableSerilogRequestResponseLoggingForRollingFile: this.EnableSerilogRequestResponseLoggingForRollingFile, serviceRequestLoggingLocationForFile: this.ServiceRequestLoggingLocationForFile);

            var tokenClient = new TokenClient(DiscoveryDoc.TokenEndpoint, ClientID, ClientSecret);

            return(await tokenClient.RequestRefreshTokenAsync(refreshToken, cancellationToken).ConfigureAwait(false));
        }
        /// <summary>
        /// Refreshes access token to get new access token
        /// </summary>
        /// <param name="refreshToken"></param>
        /// <param name="extra"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <TokenResponse> RefreshTokenAsync(string refreshToken, object extra = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            AdvancedLoggerEnabled = true;
            //Set internal property to track only informational -intuit_tid based logs
            if (EnableAdvancedLoggerInfoMode == true)
            {
                ShowInfoLogs = true;
            }
            //Intialize Logger
            AdvancedLogger = LogHelper.GetAdvancedLogging(enableSerilogRequestResponseLoggingForDebug: this.EnableSerilogRequestResponseLoggingForDebug, enableSerilogRequestResponseLoggingForTrace: this.EnableSerilogRequestResponseLoggingForTrace, enableSerilogRequestResponseLoggingForConsole: this.EnableSerilogRequestResponseLoggingForConsole, enableSerilogRequestResponseLoggingForRollingFile: this.EnableSerilogRequestResponseLoggingForRollingFile, serviceRequestLoggingLocationForFile: this.ServiceRequestLoggingLocationForFile);


            var tokenClient = new TokenClient(DiscoveryDoc.TokenEndpoint, ClientID, ClientSecret);

            return(await tokenClient.RequestRefreshTokenAsync(refreshToken, cancellationToken).ConfigureAwait(false));
        }
Exemple #5
0
        /// <summary>
        /// Refreshes access token to get new access token
        /// </summary>
        /// <param name="refreshToken"></param>
        /// <param name="extra"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <TokenResponse> RefreshTokenAsync(string refreshToken, object extra = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var tokenClient = new TokenClient(DiscoveryDoc.TokenEndpoint, ClientID, ClientSecret);

            return(await tokenClient.RequestRefreshTokenAsync(refreshToken, cancellationToken).ConfigureAwait(false));
        }