コード例 #1
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async void MainAsync(string[] args)
        {
            var apiClient = new ManagementApiClient(ConfigurationManager.AppSettings["ApiToken"], new Uri(ConfigurationManager.AppSettings["ApiBaseUrl"]));

            // Test client methods
            //await TestClientMethods(apiClient);

            // Test connection methods
            //await TestConnectionMethods(apiClient);

            // Test device credentials
            //await TestDeviceCredentialsMethods(apiClient);

            // Test rules
            //await TestRuleMethods(apiClient);

            // Test users
            //await TestUserMethods(apiClient);

            // Test user account linking
            //await TestUserAccountLinkMethods(apiClient);

            // Test emails
            //await TestEmailsMethods(apiClient);

            // Test jobs
            //await TestJobsMethods(apiClient);

            // Test stats
            //await TestStatsMethods(apiClient);

            // Test tickets
            //await TestTicketsMethods(apiClient);
        }
コード例 #2
0
        public async Task SetUp()
        {
            var scopes = new
            {
                users = new
                {
                    actions = new string[] { "create", "delete" }
                },
                connections = new
                {
                    actions = new string[] { "create", "delete" }
                }
            };
            string token = GenerateToken(scopes);

            managementApiClient = new ManagementApiClient(token, new Uri(GetVariable("AUTH0_MANAGEMENT_API_URL")));

            // We will need a connection to add the users to...
            connection = await managementApiClient.Connections.CreateAsync(new ConnectionCreateRequest
            {
                Name = Guid.NewGuid().ToString("N"),
                Strategy = "auth0",
                EnabledClients = new[] { clientId }
            });
        }
コード例 #3
0
        public async Task SetUp()
        {
            var scopes = new
            {
                users = new
                {
                    actions = new string[] { "create", "delete" }
                },
                connections = new
                {
                    actions = new string[] { "create", "delete" }
                }
            };
            string token = GenerateToken(scopes);

            managementApiClient = new ManagementApiClient(token, new Uri(GetVariable("AUTH0_MANAGEMENT_API_URL")));

            // We will need a connection to add the users to...
            connection = await managementApiClient.Connections.Create(new ConnectionCreateRequest
            {
                Name = Guid.NewGuid().ToString("N"),
                Strategy = "auth0",
                EnabledClients = new []{ "rLNKKMORlaDzrMTqGtSL9ZSXiBBksCQW" }
            });

            // And add a dummy user to test against
            user = await managementApiClient.Users.Create(new UserCreateRequest
            {
                Connection = connection.Name,
                Email = $"{Guid.NewGuid().ToString("N")}@nonexistingdomain.aaa",
                EmailVerified = true,
                Password = "******"
            });

            // Add a user with a + in the username
            plusUser = await managementApiClient.Users.Create(new UserCreateRequest
            {
                Connection = connection.Name,
                Email = $"{Guid.NewGuid().ToString("N")}[email protected]",
                EmailVerified = true,
                Password = "******"
            });
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestUserAccountLinkMethods(ManagementApiClient apiClient)
        {
            // Link user
            //var userLinkRequest = new UserAccountLinkRequest
            //{
            //    UserId = "56443cae950b505a3399c3bd",
            //    Provider = "auth0"
            //};
            //var linkResponse = await apiClient.Users.LinkAccount("auth0|56443c91950b505a3399c3b3", userLinkRequest);

            // Link user with JWT
            //var linkResponse = await apiClient.Users.LinkAccount(
            //    "auth0|56443c91950b505a3399c3b3",
            //    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2plcnJpZS5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NTY0NDNjOTE5NTBiNTA1YTMzOTljM2IzIiwiYXVkIjoiWEFDR3d3eVg4MjBGc285Z3NwelY3YTkwV3hPUGNZRW0iLCJleHAiOjE0NDc2OTU5NjEsImlhdCI6MTQ0NzY0Nzk2MX0.EipV2WM-bhSakqIOwL31UtCBAwCKhMVnAu8uNjnINqg",
            //    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2plcnJpZS5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NTY0NDNjYWU5NTBiNTA1YTMzOTljM2JkIiwiYXVkIjoiWEFDR3d3eVg4MjBGc285Z3NwelY3YTkwV3hPUGNZRW0iLCJleHAiOjE0NDc2OTU5ODAsImlhdCI6MTQ0NzY0Nzk4MH0.0u1VKZrqymSQTk7HyrJ2ACcwfohkJASMfdGL9Cp9uD0"
            //    );

            //var unlinkResponse = await apiClient.Users.UnlinkAccount("auth0|56443c91950b505a3399c3b3", "auth0", "56443cae950b505a3399c3bd");
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestUserMethods(ManagementApiClient apiClient)
        {
            // Create a new user
            //var newUserRequest = new UserCreateRequest
            //{
            //    Connection = "Username-Password-Authentication",
            //    Email = "*****@*****.**",
            //    EmailVerified = true,
            //    Password = "******"
            //};
            //var newUser = await apiClient.Users.Create(newUserRequest);

            // Get a single user
            //var user = await apiClient.Users.Get(newUser.UserId);

            // Get all users
            //var users = await apiClient.Users.GetAll();

            // Update the user
            //var updateUserRequest = new UserUpdateRequest
            //{
            //    Email = "*****@*****.**",
            //    VerifyEmail = false
            //};
            //var updatedUser = await apiClient.Users.Update(newUser.UserId, updateUserRequest);

            // Delete the user
            //await apiClient.Users.Delete(newUser.UserId);

            // Delete all users
            //await apiClient.Users.DeleteAll();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestTicketsMethods(ManagementApiClient apiClient)
        {
            // Send email verification ticket
            var ticket = await apiClient.Tickets.CreateEmailVerificationTicketAsync(new EmailVerificationTicketRequest
            {
                UserId = "auth0|56443c91950b505a3399c3b3",
                ResultUrl = "http://www.test.com/success"
            });

            // Send password change ticket
            ticket = await apiClient.Tickets.CreatePasswordChangeTicketAsync(new PasswordChangeTicketRequest
            {
                UserId = "auth0|56443c91950b505a3399c3b3",
                ResultUrl = "http://www.test.com/success",
                NewPassword = "******"
            });
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestStatsMethods(ManagementApiClient apiClient)
        {
            // Get active users
            var users = await apiClient.Stats.GetActiveUsersAsync();

            // Get daily stats
            var dailyStats = await apiClient.Stats.GetDailyStatsAsync(new DateTime(2015, 11, 1), new DateTime(2015, 11, 30));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestRuleMethods(ManagementApiClient apiClient)
        {
            // Create a new rule
            var newRuleRequest = new RuleCreateRequest
            {
                Name = "New rule",
                Script = @"function (user, context, callback) {
                              // TODO: implement your rule
                              callback(null, user, context);
                            }"
            };
            var newRule = await apiClient.Rules.CreateAsync(newRuleRequest);

            // Get a single rule
            var rule = await apiClient.Rules.GetAsync(newRule.Id);

            // Get all rules
            var rules = await apiClient.Rules.GetAllAsync();

            // Update a rule
            var updateRuleRequest = new RuleUpdateRequest
            {
                Name = "Updated rule"
            };
            var updatedRule = await apiClient.Rules.UpdateAsync(newRule.Id, updateRuleRequest);

            // Delete a rule
            await apiClient.Rules.DeleteAsync(newRule.Id);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestJobsMethods(ManagementApiClient apiClient)
        {
            // Send an email verification request
            var emailRequest = new VerifyEmailJobRequest
            {
                UserId = "auth0|56443c91950b505a3399c3b3"
            };
            var emailRequestResponse = await apiClient.Jobs.SendVerificationEmailAsync(emailRequest);

            // Get the job status
            var job = await apiClient.Jobs.GetAsync(emailRequestResponse.Id);

            // Send a user import request
            //using (FileStream fs = new FileStream("user-import-test.json", FileMode.Open))
            //{
            //    var importUsersResponse = await apiClient.Jobs.ImportUsers("con_lQKQee7ZnEGc6OYH", "user-import-test.json", fs);
            //}
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestEmailsMethods(ManagementApiClient apiClient)
        {
            // Get the email provider
            var provider = await apiClient.EmailProvider.GetAsync("name,enabled,credentials,settings");

            // Delete the email provider
            await apiClient.EmailProvider.DeleteAsync();

            // Configure the email provider
            var configureRequest = new EmailProviderConfigureRequest
            {
                Name = "mandrill",
                IsEnabled = true,
                Credentials = new EmailProviderCredentials
                {
                    ApiKey = "ABC"
                }
            };
            var configureResponse = await apiClient.EmailProvider.ConfigureAsync(configureRequest);

            // Update the email provider
            var updateRequest = new EmailProviderUpdateRequest
            {
                Name = "mandrill",
                IsEnabled = true,
                Credentials = new EmailProviderCredentials
                {
                    ApiKey = "XYZ"
                }
            };
            var updateResponse = await apiClient.EmailProvider.UpdateAsync(updateRequest);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: jerriep/auth0.net
        private static async Task TestDeviceCredentialsMethods(ManagementApiClient apiClient)
        {
            // Get all the device credentials
            //var credentials = await apiClient.DeviceCredentials.GetAll();

            // Create a new device credential
            //var newCredentialRequest = new DeviceCredentialCreateRequest
            //{
            //    DeviceName = "Jerrie's Phone",
            //    DeviceId = "ABCDEF",
            //    ClientId = "XACGwwyX820Fso9gspzV7a90WxOPcYEm",
            //    UserId = "YXV0aDB8NTYzYWZlZmViZWFlOTVmMDAxMmI1NzY5",
            //    Type = "public_key",
            //    Value = "new-key-value"
            //};
            //var credential = await apiClient.DeviceCredentials.Create(newCredentialRequest);

            // Delete a device credential
            // ...
        }