Пример #1
0
        private async Task CreateApiClients(string token)
        {
            var allowedChars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            var integrationsClient = new ApiClient()
            {
                AppName                = _integrationsApiClientName,
                Active                 = true,
                AllowAnyBuyer          = false,
                AllowAnySupplier       = false,
                AllowSeller            = true,
                AccessTokenDuration    = 600,
                RefreshTokenDuration   = 43200,
                DefaultContextUserName = _sellerUserName,
                ClientSecret           = RandomGen.GetString(allowedChars, 60)
            };
            var sellerClient = new ApiClient()
            {
                AppName              = _sellerApiClientName,
                Active               = true,
                AllowAnyBuyer        = false,
                AllowAnySupplier     = true,
                AllowSeller          = true,
                AccessTokenDuration  = 600,
                RefreshTokenDuration = 43200
            };
            var buyerClient = new ApiClient()
            {
                AppName              = _buyerApiClientName,
                Active               = true,
                AllowAnyBuyer        = true,
                AllowAnySupplier     = false,
                AllowSeller          = false,
                AccessTokenDuration  = 600,
                RefreshTokenDuration = 43200
            };
            var buyerLocalClient = new ApiClient()
            {
                AppName              = _buyerLocalApiClientName,
                Active               = true,
                AllowAnyBuyer        = true,
                AllowAnySupplier     = false,
                AllowSeller          = false,
                AccessTokenDuration  = 600,
                RefreshTokenDuration = 43200
            };

            var existingClients = await ListAllAsync.List(page => _oc.ApiClients.ListAsync(page: page, pageSize: 100, accessToken: token));

            var integrationsClientRequest = GetClientRequest(existingClients, integrationsClient, token);
            var sellerClientRequest       = GetClientRequest(existingClients, sellerClient, token);
            var buyerClientRequest        = GetClientRequest(existingClients, buyerClient, token);
            var buyerLocalClientRequest   = GetClientRequest(existingClients, buyerLocalClient, token);

            await Task.WhenAll(integrationsClientRequest, sellerClientRequest, buyerClientRequest, buyerLocalClientRequest);
        }
Пример #2
0
 public static ApiClient IntegrationsClient()
 {
     return(new ApiClient()
     {
         AppName = IntegrationsApiClientName,
         Active = true,
         AllowAnyBuyer = false,
         AllowAnySupplier = false,
         AllowSeller = true,
         AccessTokenDuration = 600,
         RefreshTokenDuration = 43200,
         DefaultContextUserName = SellerUserName,
         ClientSecret = RandomGen.GetString(AllowedSecretChars, 60)
     });
 }