Esempio n. 1
0
        /// <summary>
        /// 刷新token
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="refresh_token"></param>
        /// <returns></returns>
        protected override Task <TokenResult?> RefreshTokenAsync(IServiceProvider serviceProvider, string refresh_token)
        {
            var options = this.GetOptionsValue <ClientCredentialsOptions>();

            if (options.Endpoint == null)
            {
                throw new TokenEndPointNullException();
            }

            if (options.UseRefreshToken == false)
            {
                return(this.RequestTokenAsync(serviceProvider));
            }

            var refreshCredentials = new RefreshTokenCredentials
            {
                Client_id     = options.Credentials.Client_id,
                Client_secret = options.Credentials.Client_secret,
                Extra         = options.Credentials.Extra,
                Refresh_token = refresh_token
            };

            var clientApi = serviceProvider.GetRequiredService <IOAuthTokenClientApi>();

            return(clientApi.RefreshTokenAsync(options.Endpoint, refreshCredentials));
        }
Esempio n. 2
0
        /// <summary>
        /// 刷新token
        /// </summary>
        /// <param name="oAuthClient">Token客户端</param>
        /// <param name="refresh_token">刷新token</param>
        /// <returns></returns>
        protected override Task <TokenResult?> RefreshTokenAsync(IOAuthClient oAuthClient, string?refresh_token)
        {
            var options = this.CredentialsOptions.Value;

            if (options.Endpoint == null)
            {
                throw new TokenEndPointNullException();
            }

            var credentials = new RefreshTokenCredentials
            {
                Client_id     = options.Credentials.Client_id,
                Client_secret = options.Credentials.Client_secret,
                Extra         = options.Credentials.Extra,
                Refresh_token = refresh_token
            };

            return(oAuthClient.RefreshTokenAsync(options.Endpoint, credentials));
        }
Esempio n. 3
0
 public Task <TokenResult?> RefreshTokenAsync([Required, Uri] Uri endpoint, [Required, FormContent] RefreshTokenCredentials credentials)
 {
     return(this.PostFormAsync(endpoint, "refresh_token", credentials));
 }