use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.
the class ClientGrantsEntity method delete.
/**
* Delete an existing Client Grant. A token with scope delete:client_grants is needed.
* See https://auth0.com/docs/api/management/v2#!/Client_Grants/delete_client_grants_by_id
*
* @param clientGrantId the client grant id.
* @return a Request to execute.
*/
public Request<Void> delete(String clientGrantId) {
Asserts.assertNotNull(clientGrantId, "client grant id");
String url = baseUrl.newBuilder().addPathSegments("api/v2/client-grants").addPathSegment(clientGrantId).build().toString();
VoidRequest request = new VoidRequest(client, url, "DELETE");
request.addHeader("Authorization", "Bearer " + apiToken);
return request;
}
use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.
the class EmailProviderEntity method delete.
/**
* Delete the existing Email Provider. A token with scope delete:email_provider is needed.
* See https://auth0.com/docs/api/management/v2#!/Emails/delete_provider
*
* @return a Request to execute.
*/
public Request<Void> delete() {
String url = baseUrl.newBuilder().addPathSegments("api/v2/emails/provider").build().toString();
VoidRequest request = new VoidRequest(client, url, "DELETE");
request.addHeader("Authorization", "Bearer " + apiToken);
return request;
}
use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.
the class GrantsEntity method delete.
/**
* Delete an existing Grant. A token with scope delete:grants is needed.
* See https://auth0.com/docs/api/management/v2#!/Grants/delete_grants_by_id<br>
*
* @param grantId The id of the grant to delete.
* @return a Request to execute.
*/
public Request<Void> delete(String grantId) {
Asserts.assertNotNull(grantId, "grant id");
final String url = baseUrl.newBuilder().addPathSegments("api/v2/grants").addPathSegment(grantId).build().toString();
VoidRequest request = new VoidRequest(client, url, "DELETE");
request.addHeader("Authorization", "Bearer " + apiToken);
return request;
}
use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.
the class GrantsEntity method deleteAll.
/**
* Deletes all Grants of a given user. A token with scope delete:grants is needed.
* See https://auth0.com/docs/api/management/v2#!/Grants/delete_grants_by_id<br>
*
* @param userId The id of the user whose grants are deleted.
* @return a Request to execute.
*/
public Request<Void> deleteAll(String userId) {
Asserts.assertNotNull(userId, "user id");
final String url = baseUrl.newBuilder().addPathSegments("api/v2/grants").addQueryParameter("user_id", userId).build().toString();
VoidRequest request = new VoidRequest(client, url, "DELETE");
request.addHeader("Authorization", "Bearer " + apiToken);
return request;
}
use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.
the class ClientGrantsEntityTest method shouldCreateClientGrant.
@Test
public void shouldCreateClientGrant() throws Exception {
Request<ClientGrant> request = api.clientGrants().create("clientId", "audience", new String[] { "openid" });
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_CLIENT_GRANT, 200);
ClientGrant response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/client-grants"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(3));
assertThat(body, hasEntry("client_id", "clientId"));
assertThat(body, hasEntry("audience", "audience"));
assertThat(body, hasKey("scope"));
assertThat((Iterable<?>) body.get("scope"), contains("openid"));
assertThat(response, is(notNullValue()));
}
Aggregations