Skip to content

Providing new method to enable patch clients credential endpoint #714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/java/com/auth0/client/mgmt/ClientsEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,32 @@ public Request<Void> deleteCredential(String clientId, String credentialId) {
.toString();
return new VoidRequest(client, tokenProvider, url, HttpMethod.DELETE);
}

/**
* Update an existing client credential. A token with scope update:client_credentials is needed.
* See https://auth0.com/docs/api/management/v2/clients/patch-credentials-by-credential-id
*
* @param clientId the application's client id.
* @param credentialId the ID of the credential.
* @param credential the credential to update.
* @return a Request to execute.
*/
public Request<Credential> updateCredential(String clientId, String credentialId, Credential credential) {
Asserts.assertNotNull(clientId, "client id");
Asserts.assertNotNull(credentialId, "credential id");
Asserts.assertNotNull(credential, "credential");

String url = baseUrl
.newBuilder()
.addPathSegments("api/v2/clients")
.addPathSegment(clientId)
.addPathSegment("credentials")
.addPathSegment(credentialId)
.build()
.toString();
BaseRequest<Credential> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.PATCH, new TypeReference<Credential>() {
});
request.setBody(credential);
return request;
}
}