WorkOS PHP SDK

Connect
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
completeOAuth2()  : ExternalAuthCompleteResponse
Complete external authentication
createApplicationClientSecret()  : NewConnectApplicationSecret
Create a new client secret for a Connect Application
createM2MApplication()  : ConnectApplication
createOAuthApplication()  : ConnectApplication
deleteApplication()  : void
Delete a Connect Application
deleteClientSecret()  : void
Delete a Client Secret
getApplication()  : ConnectApplication
Get a Connect Application
listApplicationClientSecrets()  : array<string|int, mixed>
List Client Secrets for a Connect Application
listApplications()  : PaginatedResponse<string|int, ConnectApplication>
List Connect Applications
updateApplication()  : ConnectApplication
Update a Connect Application

Properties

Methods

completeOAuth2()

Complete external authentication

public completeOAuth2(string $externalAuthId, UserObject $user[, array<string|int, UserConsentOption>|null $userConsentOptions = null ][, RequestOptions|null $options = null ]) : ExternalAuthCompleteResponse

Completes an external authentication flow and returns control to AuthKit. This endpoint is used with Standalone Connect to bridge your existing authentication system with the Connect OAuth API infrastructure.

After successfully authenticating a user in your application, calling this endpoint will:

  • Create or update the user in AuthKit, using the given id as its external_id.
  • Return a redirect_uri your application should redirect to in order for AuthKit to complete the flow

Users are automatically created or updated based on the id and email provided. If a user with the same id exists, their information is updated. Otherwise, a new user is created.

If you provide a new id with an email that already belongs to an existing user, the request will fail with an error as email addresses are unique to a user.

Parameters
$externalAuthId : string

Identifier provided when AuthKit redirected to your login page.

$user : UserObject

The user to create or update in AuthKit.

$userConsentOptions : array<string|int, UserConsentOption>|null = null

Array of User Consent Options to store with the session.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
ExternalAuthCompleteResponse

createM2MApplication()

public createM2MApplication(string $name, string $organizationId[, string|null $description = null ][, array<string|int, string>|null $scopes = null ][, RequestOptions|null $options = null ]) : ConnectApplication
Parameters
$name : string
$organizationId : string
$description : string|null = null
$scopes : array<string|int, string>|null = null
$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
ConnectApplication

createOAuthApplication()

public createOAuthApplication(string $name, bool $isFirstParty[, string|null $description = null ][, array<string|int, string>|null $scopes = null ][, array<string|int, RedirectUriInput>|null $redirectUris = null ][, bool|null $usesPkce = null ][, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : ConnectApplication
Parameters
$name : string
$isFirstParty : bool
$description : string|null = null
$scopes : array<string|int, string>|null = null
$redirectUris : array<string|int, RedirectUriInput>|null = null
$usesPkce : bool|null = null
$organizationId : string|null = null
$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
ConnectApplication

deleteApplication()

Delete a Connect Application

public deleteApplication(string $id[, RequestOptions|null $options = null ]) : void

Delete an existing Connect Application.

Parameters
$id : string

The application ID or client ID of the Connect Application.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

deleteClientSecret()

Delete a Client Secret

public deleteClientSecret(string $id[, RequestOptions|null $options = null ]) : void

Delete (revoke) an existing client secret.

Parameters
$id : string

The unique ID of the client secret.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

listApplicationClientSecrets()

List Client Secrets for a Connect Application

public listApplicationClientSecrets(string $id[, RequestOptions|null $options = null ]) : array<string|int, mixed>

List all client secrets associated with a Connect Application.

Parameters
$id : string

The application ID or client ID of the Connect Application.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
array<string|int, mixed>

listApplications()

List Connect Applications

public listApplications([string|null $before = null ][, string|null $after = null ][, int|null $limit = null ][, EventsOrder $order = EventsOrder::Desc ][, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : PaginatedResponse<string|int, ConnectApplication>

List all Connect Applications in the current environment with optional filtering.

Parameters
$before : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include before="obj_123" to fetch a new batch of objects before "obj_123".

$after : string|null = null

An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with "obj_123", your subsequent call can include after="obj_123" to fetch a new batch of objects after "obj_123".

$limit : int|null = null

Upper limit on the number of objects to return, between 1 and 100. Defaults to 10.

$order : EventsOrder = EventsOrder::Desc

Order the results by the creation time. Supported values are "asc" (ascending), "desc" (descending), and "normal" (descending with reversed cursor semantics where before fetches older records and after fetches newer records). Defaults to descending. Defaults to "desc".

$organizationId : string|null = null

Filter Connect Applications by organization ID.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
PaginatedResponse<string|int, ConnectApplication>

updateApplication()

Update a Connect Application

public updateApplication(string $id[, string|null $name = null ][, string|null $description = null ][, array<string|int, string>|null $scopes = null ][, array<string|int, RedirectUriInput>|null $redirectUris = null ][, RequestOptions|null $options = null ]) : ConnectApplication

Update an existing Connect Application. For OAuth applications, you can update redirect URIs. For all applications, you can update the name, description, and scopes.

Parameters
$id : string

The application ID or client ID of the Connect Application.

$name : string|null = null

The name of the application.

$description : string|null = null

A description for the application.

$scopes : array<string|int, string>|null = null

The OAuth scopes granted to the application.

$redirectUris : array<string|int, RedirectUriInput>|null = null

Updated redirect URIs for the application. OAuth applications only.

$options : RequestOptions|null = null
Tags
throws
WorkOSException
Return values
ConnectApplication

        
On this page

Search results