Esempio n. 1
0
        public static async Task MainAsync()
        {
            Console.Title = "Console Client Credentials Flow";
            var identityAdminClient = new Hubx.Net.Identity.Models.IdentityClient()
            {
                ClientId     = "generic-client",
                ClientSecret = "generic-secret",
                ClientScope  = "admin-api",
                Authority    = "http://localhost:5000",
                ResourceUri  = "http://localhost:5005"
            };
            var identityBuyerClient = new Hubx.Net.Identity.Models.IdentityClient()
            {
                ClientId     = "buyer-only-client",
                ClientSecret = "buyer-secret",
                ClientScope  = "buyer-api",
                Authority    = "http://localhost:5000",
                ResourceUri  = "http://localhost:5015"
            };
            var identityVendorClient = new Hubx.Net.Identity.Models.IdentityClient()
            {
                ClientId     = "vendor-only-client",
                ClientSecret = "vendor-secret",
                ClientScope  = "vendor-api",
                Authority    = "http://localhost:5000",
                ResourceUri  = "http://localhost:5025"
            };

            await RunProcess(
                identityAdminClient);
            await RunProcess(
                identityBuyerClient);
            await RunProcess(
                identityVendorClient);
        }
Esempio n. 2
0
        static async Task <bool> RequestDataSet_NotAuthenticated_ApiAsync(Hubx.Net.Identity.Models.IdentityClient identity)
        {
            var client   = new HttpClient();
            var response = await client.GetAsync(identity.ResourceUri + "/dataset");

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.StatusCode);
            }
            else
            {
                identity.Message = response.Content.ReadAsStringAsync().Result;
                Console.WriteLine(JArray.Parse(identity.Message));
            }
            return(true);
        }
Esempio n. 3
0
        public static async Task MainAsync()
        {
            Console.Title = "Console Client Credentials Flow";
            var identityAdminClient = new Hubx.Net.Identity.Models.IdentityClient()
            {
                ClientId     = "generic-client",
                ClientSecret = "generic-secret",
                ClientScope  = "admin-api",
                Authority    = "http://localhost:5000",
                ResourceUri  = "http://localhost:5005"
            };
            var identityBuyerClient = new Hubx.Net.Identity.Models.IdentityClient()
            {
                ClientId     = "buyer-only-client",
                ClientSecret = "buyer-secret",
                ClientScope  = "buyer-api",
                Authority    = "http://localhost:5000",
                ResourceUri  = "http://localhost:5015"
            };
            var identityVendorClient = new Hubx.Net.Identity.Models.IdentityClient()
            {
                ClientId     = "vendor-only-client",
                ClientSecret = "vendor-secret",
                ClientScope  = "vendor-api",
                Authority    = "http://localhost:5000",
                ResourceUri  = "http://localhost:5025"
            };

            // await RequestDataSetApiAsync(identityAdminClient);
            // await RequestDataSetNotAuthenticatedApiAsync(identityAdminClient);

            await RunProcess(identityAdminClient);
            await RunProcess(identityBuyerClient);
            await RunProcess(identityVendorClient);

            //identityAdminClient.TokenResponse = await RequestTokenAsync(identityAdminClient);

            //if (await RequestApiAsync(identityAdminClient))
            //{
            //    if (identityAdminClient.ClientId!="") {
            //        await RequestDataSetApiAsync(identityAdminClient);
            //    }
            //}
        }
Esempio n. 4
0
        static async Task <bool> RequestApiAsync(Hubx.Net.Identity.Models.IdentityClient identity)
        {
            var client = new HttpClient();

            client.SetBearerToken(identity.TokenResponse.AccessToken);
            var response = await client.GetAsync(identity.ResourceUri + "/identity");

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.StatusCode);
            }
            else
            {
                identity.Message = response.Content.ReadAsStringAsync().Result;

                Console.WriteLine(JArray.Parse(identity.Message));
            }
            return(true);
        }