use of com.auth0.json.mgmt.Grant 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.Grant 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.Grant in project auth0-java by auth0.
the class GrantsEntityTest method shouldListGrants.
@Test
public void shouldListGrants() throws Exception {
@SuppressWarnings("deprecation") Request<List<Grant>> request = api.grants().list("userId");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_GRANTS_LIST, 200);
List<Grant> response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/grants"));
assertThat(recordedRequest, hasQueryParameter("user_id", "userId"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(response, is(notNullValue()));
assertThat(response, hasSize(2));
for (Grant grant : response) {
assertThat(grant.getAudience(), notNullValue());
assertThat(grant.getClientId(), notNullValue());
assertThat(grant.getId(), notNullValue());
assertThat(grant.getScope(), notNullValue());
assertThat(grant.getScope(), hasSize(2));
assertThat(grant.getUserId(), equalTo("userId"));
}
}
Aggregations