Example #1
0
        public async Task <TokenResponse> RequestPasswordTokenAsync(string userName, string password)
        {
            DiscoveryDocumentResponse disco = await AuthHttpClient.GetDiscoveryDocumentAsync(DiscoveryDocument);

            if (disco.IsError)
            {
                throw new Exception(disco.Error);
            }
            TokenResponse response = await AuthHttpClient.RequestPasswordTokenAsync(new PasswordTokenRequest
            {
                Address      = disco.TokenEndpoint,
                Scope        = Configuration["Scope"],
                GrantType    = Configuration["GrantType"],
                ClientId     = Configuration["ClientId"],
                ClientSecret = Configuration["ClientSecret"],

                UserName = userName,
                Password = password,
            });

            if (response.IsError)
            {
                throw new Exception(response.Error);
            }
            return(HttpToken = response);
        }
Example #2
0
        public async Task <DeviceAuthorizationResponse> RequestDeviceAuthorizationAsync()
        {
            DiscoveryDocumentResponse disco = await DiscoveryCache.GetAsync();

            if (disco.IsError)
            {
                throw new Exception(disco.Error);
            }

            DeviceAuthorizationResponse response = await AuthHttpClient.RequestDeviceAuthorizationAsync(new DeviceAuthorizationRequest
            {
                Address      = disco.DeviceAuthorizationEndpoint,
                Scope        = Configuration["Scope"],
                ClientId     = Configuration["ClientId"],
                ClientSecret = Configuration["ClientSecret"],
            });

            string           url  = $"{ response.VerificationUri}?userCode={ response.UserCode}";
            ProcessStartInfo proc = new ProcessStartInfo(url)
            {
                UseShellExecute = true
            };

            Process.Start(proc);
            return(response);
        }
Example #3
0
 public Task <TokenResponse> RequestDeviceTokenAsync(string deviceCode)
 {
     return(AuthHttpClient.RequestDeviceTokenAsync(new DeviceTokenRequest()
     {
         DeviceCode = deviceCode
     }));
 }
Example #4
0
 public Task <TokenResponse> RequestRefreshTokenAsync(string refreshToken, string scope)
 {
     return(AuthHttpClient.RequestRefreshTokenAsync(new RefreshTokenRequest()
     {
         RefreshToken = refreshToken,
         Scope = scope
     }));
 }
Example #5
0
 public Task <TokenResponse> RequestAuthorizationCodeTokenAsync(string code, string redirectUri, string codeVerifier)
 {
     return(AuthHttpClient.RequestAuthorizationCodeTokenAsync(new AuthorizationCodeTokenRequest()
     {
         Code = code,
         RedirectUri = redirectUri,
         CodeVerifier = codeVerifier,
     }));
 }
Example #6
0
        public async Task <TokenResponse> RequestTokenAsync()
        {
            DiscoveryDocumentResponse disco = await DiscoveryCache.GetAsync();

            return(await AuthHttpClient.RequestTokenAsync(new TokenRequest()
            {
                Address = disco.TokenEndpoint,
                GrantType = Configuration["GrantType"],
                ClientId = Configuration["ClientId"],
                ClientSecret = Configuration["ClientSecret"],
            }));
        }
Example #7
0
        public PlaidClient(IHttpClientFactory httpClientFactory)
        {
            var httpClient = httpClientFactory.CreateClient("plaid");

            Sandbox      = new SandboxHttpClient(httpClient);
            Institutions = new InstitutionsHttpClient(httpClient);
            Categories   = new CategoriesHttpClient(httpClient);
            Accounts     = new AccountsHttpClient(httpClient);
            Items        = new ItemsHttpClient(httpClient);
            Transactions = new TransactionsHttpClient(httpClient);
            Income       = new IncomeHttpClient(httpClient);
            Identity     = new IdentityHttpClient(httpClient);
            Auth         = new AuthHttpClient(httpClient);
        }
Example #8
0
        public async Task <TokenIntrospectionResponse> IntrospectTokenAsync(string accessToken)
        {
            DiscoveryDocumentResponse disco = await DiscoveryCache.GetAsync();

            if (disco.IsError)
            {
                throw new Exception(disco.Error);
            }
            TokenIntrospectionResponse result = await AuthHttpClient.IntrospectTokenAsync(
                new TokenIntrospectionRequest
            {
                Address      = disco.IntrospectionEndpoint,
                ClientId     = Configuration["ClientId"],
                ClientSecret = Configuration["ClientSecret"],
                Token        = accessToken
            });

            return(result);
        }
Example #9
0
        public async Task <UserInfoResponse> GetUserinfoAsync()
        {
            DiscoveryDocumentResponse disco = await DiscoveryCache.GetAsync();

            if (disco.IsError)
            {
                throw new Exception(disco.Error);
            }

            UserInfoResponse response = await AuthHttpClient.GetUserInfoAsync(new UserInfoRequest
            {
                Address = disco.UserInfoEndpoint,
                Token   = await ReadAsync()
            });;

            if (response.IsError)
            {
                throw new Exception(response.Error);
            }
            return(response);
        }
Example #10
0
        public async Task <TokenResponse> RequestClientCredentialsTokenAsync()
        {
            DiscoveryDocumentResponse disco = await AuthHttpClient.GetDiscoveryDocumentAsync(DiscoveryDocument);

            if (disco.IsError)
            {
                throw new Exception(disco.Error);
            }

            TokenResponse response = await AuthHttpClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
            {
                Address      = disco.TokenEndpoint,
                Scope        = Configuration["Scope"],
                GrantType    = Configuration["GrantType"],
                ClientId     = Configuration["ClientId"],
                ClientSecret = Configuration["ClientSecret"],
            });

            if (response.IsError)
            {
                throw new Exception(response.Error);
            }
            return(HttpToken = response);
        }
Example #11
0
 public Task <TokenResponse> RequestTokenRawAsync()
 {
     return(AuthHttpClient.RequestTokenRawAsync("", new Dictionary <string, string>()
     {
     }));
 }
Example #12
0
 public Task <TokenResponse> RequestTokenExchangeTokenAsync()
 {
     return(AuthHttpClient.RequestTokenExchangeTokenAsync(new TokenExchangeTokenRequest()
     {
     }));
 }
Example #13
0
        public Task <HttpResponseMessage> IntrospectAsync(IEnumerable <KeyValuePair <string, string> > values)
        {
            string json = JsonConvert.SerializeObject(values);

            return(AuthHttpClient.PostAsync("/connect/introspect", new StringContent(json, Encoding.UTF8, "text/json")));
        }
Example #14
0
 public Task <HttpResponseMessage> CheckSessionAsync()
 {
     return(AuthHttpClient.GetAsync("/connect/checksession"));
 }