Example #1
0
        public async Task Test_device_credentials_crud_sequence()
        {
            var apiClient = new ManagementApiClient(GetVariable("AUTH0_TOKEN_DEVICE_CREDENTIALS"), new Uri(GetVariable("AUTH0_MANAGEMENT_API_URL")));

            //Get all the device credentials
            var credentialsBefore = await apiClient.DeviceCredentials.GetAllAsync();

            //Create a new device credential
            var newCredentialRequest = new DeviceCredentialCreateRequest
            {
                DeviceName = Guid.NewGuid().ToString("N"),
                DeviceId   = Guid.NewGuid().ToString("N"),
                ClientId   = client.ClientId,
                Type       = "public_key",
                Value      = "new-key-value"
            };
            var newCredentialResponse = await apiClient.DeviceCredentials.CreateAsync(newCredentialRequest);

            newCredentialResponse.Should().NotBeNull();
            newCredentialResponse.DeviceId.Should().Be(newCredentialRequest.DeviceId);
            newCredentialResponse.DeviceName.Should().Be(newCredentialRequest.DeviceName);

            // Check that we now have one more device credential
            var credentialsAfterCreate = await apiClient.DeviceCredentials.GetAllAsync();

            credentialsAfterCreate.Count.Should().Be(credentialsBefore.Count + 1);

            // Delete the device credential
            await apiClient.DeviceCredentials.DeleteAsync(newCredentialResponse.Id);

            // Check that we now have one less device credential
            var credentialsAfterDelete = await apiClient.DeviceCredentials.GetAllAsync();

            credentialsAfterDelete.Count.Should().Be(credentialsAfterCreate.Count - 1);
        }
Example #2
0
 public Task <DeviceCredential> Create(DeviceCredentialCreateRequest request)
 {
     return(CreateAsync(request));
 }
 /// <summary>
 /// Creates a new device credential.
 /// </summary>
 /// <param name="request">The request containing the details of the device credential to create.</param>
 /// <returns>The newly created <see cref="DeviceCredential"/>.</returns>
 public Task <DeviceCredential> CreateAsync(DeviceCredentialCreateRequest request)
 {
     return(Connection.PostAsync <DeviceCredential>("device-credentials", request, null, null, null, null, null));
 }
 /// <summary>
 /// Creates a new device credential.
 /// </summary>
 /// <param name="request">The request containing the details of the device credential to create.</param>
 /// <returns>The newly created <see cref="DeviceCredential"/>.</returns>
 public Task <DeviceCredential> CreateAsync(DeviceCredentialCreateRequest request)
 {
     return(Connection.SendAsync <DeviceCredential>(HttpMethod.Post, BuildUri("device-credentials"), request, DefaultHeaders));
 }