Search in sources :

Example 11 with Client

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;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 12 with Client

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;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 13 with Client

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;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 14 with Client

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;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 15 with Client

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()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ClientGrant(com.auth0.json.mgmt.ClientGrant) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)36 APIException (com.auth0.exception.APIException)27 Auth0Exception (com.auth0.exception.Auth0Exception)27 RateLimitException (com.auth0.exception.RateLimitException)27 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)26 List (java.util.List)25 Test (org.junit.Test)25 VoidRequest (com.auth0.net.VoidRequest)24 TokenHolder (com.auth0.json.auth.TokenHolder)22 JsonParseException (com.fasterxml.jackson.core.JsonParseException)19 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)19 ExpectedException (org.junit.rules.ExpectedException)19 RecordedMultipartRequest (com.auth0.net.multipart.RecordedMultipartRequest)16 Test (org.junit.jupiter.api.Test)14 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)14 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)13 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)9 AuthAPI (com.auth0.client.auth.AuthAPI)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 OkHttpClient (okhttp3.OkHttpClient)7