Skip to content

Latest commit

 

History

History
334 lines (234 loc) · 15.7 KB

File metadata and controls

334 lines (234 loc) · 15.7 KB

OauthApplications

(oauthApplications())

Overview

Available Operations

  • 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

list

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.

Example Usage

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
        }
    }
}

Parameters

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.

Response

ListOAuthApplicationsResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 403, 422 application/json
models/errors/SDKError 4XX, 5XX */*

create

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...

Example Usage

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
        }
    }
}

Parameters

Parameter Type Required Description
request CreateOAuthApplicationRequestBody ✔️ The request object to use for the request.

Response

CreateOAuthApplicationResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 400, 403, 422 application/json
models/errors/SDKError 4XX, 5XX */*

get

Fetches the OAuth application whose ID matches the provided id in the path.

Example Usage

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
        }
    }
}

Parameters

Parameter Type Required Description
oauthApplicationId String ✔️ The ID of the OAuth application

Response

GetOAuthApplicationResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*

update

Updates an existing OAuth application

Example Usage

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
        }
    }
}

Parameters

Parameter Type Required Description
oauthApplicationId String ✔️ The ID of the OAuth application to update
requestBody UpdateOAuthApplicationRequestBody ✔️ N/A

Response

UpdateOAuthApplicationResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403, 404, 422 application/json
models/errors/SDKError 4XX, 5XX */*

delete

Deletes the given OAuth application. This is not reversible.

Example Usage

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
        }
    }
}

Parameters

Parameter Type Required Description
oauthApplicationId String ✔️ The ID of the OAuth application to delete

Response

DeleteOAuthApplicationResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*

rotateSecret

Rotates the OAuth application's client secret. When the client secret is rotated, make sure to update it in authorized OAuth clients.

Example Usage

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
        }
    }
}

Parameters

Parameter Type Required Description
oauthApplicationId String ✔️ The ID of the OAuth application for which to rotate the client secret

Response

RotateOAuthApplicationSecretResponse

Errors

Error Type Status Code Content Type
models/errors/ClerkErrors 403, 404 application/json
models/errors/SDKError 4XX, 5XX */*