Search in sources :

Example 6 with Client

use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.

the class OrganizationsEntity method addMembers.

/**
 * Add members to an organization. A token with {@code create:organization_members} scope is required.
 *
 * @param orgId the ID of the organization
 * @param members The members to add
 * @return a Request to execute
 *
 * @see <a href="https://auth0.com/docs/api/management/v2#!/Organizations/post_members">https://auth0.com/docs/api/management/v2#!/Organizations/post_members</a>
 */
public Request<Void> addMembers(String orgId, Members members) {
    Asserts.assertNotNull(orgId, "organization ID");
    Asserts.assertNotNull(members, "members");
    String url = baseUrl.newBuilder().addPathSegments(ORGS_PATH).addPathSegment(orgId).addPathSegment("members").build().toString();
    VoidRequest request = new VoidRequest(client, url, "POST");
    request.addHeader(AUTHORIZATION_HEADER, "Bearer " + apiToken);
    request.setBody(members);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 7 with Client

use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.

the class OrganizationsEntity method deleteConnection.

/**
 * Delete a connection from an organization. A token with {@code delete:organization_connections} scope is required.
 *
 * @param orgId the ID of the organization
 * @param connectionId the ID of the connection to delete
 * @return a Request to execute
 *
 * @see <a href="https://auth0.com/docs/api/management/v2#!/Organizations/delete_enabled_connections_by_connectionId">https://auth0.com/docs/api/management/v2#!/Organizations/delete_enabled_connections_by_connectionId</a>
 */
public Request<Void> deleteConnection(String orgId, String connectionId) {
    Asserts.assertNotNull(orgId, "organization ID");
    Asserts.assertNotNull(connectionId, "connection ID");
    String url = baseUrl.newBuilder().addPathSegments(ORGS_PATH).addPathSegment(orgId).addPathSegment("enabled_connections").addPathSegment(connectionId).build().toString();
    VoidRequest voidRequest = new VoidRequest(client, url, "DELETE");
    voidRequest.addHeader(AUTHORIZATION_HEADER, "Bearer " + apiToken);
    return voidRequest;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 8 with Client

use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.

the class OrganizationsEntity method deleteMembers.

/**
 * Delete members from an organization. A token with {@code delete:organization_members} scope is required.
 *
 * @param orgId the ID of the organization
 * @param members The members to remove
 * @return a Request to execute
 *
 * @see <a href="https://auth0.com/docs/api/management/v2#!/Organizations/delete_members">https://auth0.com/docs/api/management/v2#!/Organizations/delete_members</a>
 */
public Request<Void> deleteMembers(String orgId, Members members) {
    Asserts.assertNotNull(orgId, "organization ID");
    Asserts.assertNotNull(members, "members");
    String url = baseUrl.newBuilder().addPathSegments(ORGS_PATH).addPathSegment(orgId).addPathSegment("members").build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader(AUTHORIZATION_HEADER, "Bearer " + apiToken);
    request.setBody(members);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 9 with Client

use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.

the class ResourceServerEntity method delete.

/**
 * Creates request for delete resource server by it's ID
 * See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/delete_resource_servers_by_id>API documentation</a>
 *
 * @param resourceServerId {@link ResourceServer#id} field
 * @return request to execute
 */
public Request<Void> delete(String resourceServerId) {
    Asserts.assertNotNull(resourceServerId, "Resource server ID");
    HttpUrl.Builder builder = baseUrl.newBuilder().addPathSegments("api/v2/resource-servers").addPathSegment(resourceServerId);
    String url = builder.build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest) HttpUrl(okhttp3.HttpUrl)

Example 10 with Client

use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.

the class BlacklistsEntity method blacklistToken.

/**
 * Add a Token to the Blacklist. A token with scope blacklist:tokens is needed.
 * See https://auth0.com/docs/api/management/v2#!/Blacklists/post_tokens.
 *
 * @param token the token to blacklist.
 * @return a Request to execute.
 */
public Request<Void> blacklistToken(Token token) {
    Asserts.assertNotNull(token, "token");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/blacklists/tokens").build().toString();
    VoidRequest request = new VoidRequest(client, url, "POST");
    request.addHeader("Authorization", "Bearer " + apiToken);
    request.setBody(token);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

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