(oauthApplications())
- list - Get a list of OAuth applications for an instance
- create - Create an OAuth application
- get - Retrieve an OAuth application by ID
- update - Update an OAuth application
- delete - Delete an OAuth application
- rotateSecret - Rotate the client secret of the given OAuth application
This request returns the list of OAuth applications for an instance.
Results can be paginated using the optional limit
and offset
query parameters.
The OAuth applications are ordered by descending creation date.
Most recent OAuth applications will be returned first.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.ListOAuthApplicationsResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
ListOAuthApplicationsResponse res = sdk.oauthApplications().list()
.limit(10L)
.offset(0L)
.call();
if (res.oAuthApplications().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
limit |
Optional<Long> | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
offset |
Optional<Long> | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 400, 403, 422 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
Creates a new OAuth application with the given name and callback URL for an instance.
The callback URL must be a valid url.
All URL schemes are allowed such as http://
, https://
, myapp://
, etc...
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.CreateOAuthApplicationRequestBody;
import com.clerk.backend_api.models.operations.CreateOAuthApplicationResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
CreateOAuthApplicationRequestBody req = CreateOAuthApplicationRequestBody.builder()
.name("<value>")
.callbackUrl("https://probable-heating.com/")
.scopes("profile email public_metadata")
.build();
CreateOAuthApplicationResponse res = sdk.oauthApplications().create()
.request(req)
.call();
if (res.oAuthApplicationWithSecret().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
request |
CreateOAuthApplicationRequestBody | ✔️ | The request object to use for the request. |
CreateOAuthApplicationResponse
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 400, 403, 422 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
Fetches the OAuth application whose ID matches the provided id
in the path.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.GetOAuthApplicationResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
GetOAuthApplicationResponse res = sdk.oauthApplications().get()
.oauthApplicationId("<id>")
.call();
if (res.oAuthApplication().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
oauthApplicationId |
String | ✔️ | The ID of the OAuth application |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 403, 404 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
Updates an existing OAuth application
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.UpdateOAuthApplicationRequestBody;
import com.clerk.backend_api.models.operations.UpdateOAuthApplicationResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
UpdateOAuthApplicationResponse res = sdk.oauthApplications().update()
.oauthApplicationId("<id>")
.requestBody(UpdateOAuthApplicationRequestBody.builder()
.scopes("profile email public_metadata private_metadata")
.build())
.call();
if (res.oAuthApplication().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
oauthApplicationId |
String | ✔️ | The ID of the OAuth application to update |
requestBody |
UpdateOAuthApplicationRequestBody | ✔️ | N/A |
UpdateOAuthApplicationResponse
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 403, 404, 422 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
Deletes the given OAuth application. This is not reversible.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.DeleteOAuthApplicationResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
DeleteOAuthApplicationResponse res = sdk.oauthApplications().delete()
.oauthApplicationId("<id>")
.call();
if (res.deletedObject().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
oauthApplicationId |
String | ✔️ | The ID of the OAuth application to delete |
DeleteOAuthApplicationResponse
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 403, 404 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |
Rotates the OAuth application's client secret. When the client secret is rotated, make sure to update it in authorized OAuth clients.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.errors.ClerkErrors;
import com.clerk.backend_api.models.operations.RotateOAuthApplicationSecretResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws ClerkErrors, Exception {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
RotateOAuthApplicationSecretResponse res = sdk.oauthApplications().rotateSecret()
.oauthApplicationId("<id>")
.call();
if (res.oAuthApplicationWithSecret().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
oauthApplicationId |
String | ✔️ | The ID of the OAuth application for which to rotate the client secret |
RotateOAuthApplicationSecretResponse
Error Type | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 403, 404 | application/json |
models/errors/SDKError | 4XX, 5XX | */* |