public async Task Test_client_credentials_crud_sequence() { // Get all the current client grants var clientGrantsBefore = await _apiClient.ClientGrants.GetAllAsync(); // Add a new client grant var newClientGrantRequest = new ClientGrantCreateRequest { ClientId = _client.ClientId, Audience = _resourceServer.Identifier, Scope = new List <string> { "scope1", "scope2" } }; var newClientGrantResponse = await _apiClient.ClientGrants.CreateAsync(newClientGrantRequest); newClientGrantResponse.Should().NotBeNull(); newClientGrantResponse.ShouldBeEquivalentTo(newClientGrantRequest, options => options.Excluding(cg => cg.Id)); // Get all the client grants again, and verify we have one more var clientGrantsAfter = await _apiClient.ClientGrants.GetAllAsync(); clientGrantsAfter.Count.Should().Be(clientGrantsBefore.Count + 1); // Update the client grant var updateClientGrantRequest = new ClientGrantUpdateRequest { Scope = new List <string> { "scope3" } }; var updateClientGrantResponse = await _apiClient.ClientGrants.UpdateAsync(newClientGrantResponse.Id, updateClientGrantRequest); updateClientGrantResponse.Should().NotBeNull(); updateClientGrantResponse.Scope.Count.Should().Be(1); updateClientGrantResponse.Scope[0].Should().Be("scope3"); // Delete the client grant await _apiClient.ClientGrants.DeleteAsync(newClientGrantResponse.Id); }
/// <summary> /// Creates a new client grant. /// </summary> /// <param name="request">The <see cref="ClientGrantCreateRequest"/> containing the properties of the Client Grant.</param> /// <returns>The new <see cref="ClientGrant"/> that has been created.</returns> public Task <ClientGrant> CreateAsync(ClientGrantCreateRequest request) { return(Connection.SendAsync <ClientGrant>(HttpMethod.Post, BuildUri("client-grants"), request, DefaultHeaders)); }
/// <summary> /// Creates a new client grant. /// </summary> /// <param name="request">The <see cref="ClientGrantCreateRequest"/> containing the properties of the Client Grant.</param> /// <returns>The new <see cref="ClientGrant"/> that has been created.</returns> public Task <ClientGrant> CreateAsync(ClientGrantCreateRequest request) { return(Connection.PostAsync <ClientGrant>("client-grants", request, null, null, null, null, null)); }