WorkOS PHP SDK

Pipes
in package

Table of Contents

Properties

$client  : HttpClient

Methods

__construct()  : mixed
authorizeDataIntegration()  : DataIntegrationAuthorizeUrlResponse
Get authorization URL
createDataIntegrationToken()  : DataIntegrationAccessTokenResponse
Get an access token for a connected account
deleteUserConnectedAccount()  : void
Delete a connected account
getUserConnectedAccount()  : ConnectedAccount
Get a connected account
listUserDataProviders()  : DataIntegrationsListResponse
List providers

Properties

Methods

authorizeDataIntegration()

Get authorization URL

public authorizeDataIntegration(string $slug, string $userId[, string|null $organizationId = null ][, string|null $returnTo = null ][, RequestOptions|null $options = null ]) : DataIntegrationAuthorizeUrlResponse

Generates an OAuth authorization URL to initiate the connection flow for a user. Redirect the user to the returned URL to begin the OAuth flow with the third-party provider.

Parameters
$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$userId : string

The ID of the user to authorize.

$organizationId : string|null = null

An organization ID to scope the authorization to a specific organization.

$returnTo : string|null = null

The URL to redirect the user to after authorization.

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

createDataIntegrationToken()

Get an access token for a connected account

public createDataIntegrationToken(string $slug, string $userId[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : DataIntegrationAccessTokenResponse

Fetches a valid OAuth access token for a user's connected account. WorkOS automatically handles token refresh, ensuring you always receive a valid, non-expired token.

Parameters
$slug : string

The identifier of the integration.

$userId : string

A User identifier.

$organizationId : string|null = null

An Organization identifier. Optional parameter to scope the connection to a specific organization.

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

deleteUserConnectedAccount()

Delete a connected account

public deleteUserConnectedAccount(string $userId, string $slug[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : void

Disconnects WorkOS's account for the user, including removing any stored access and refresh tokens. The user will need to reauthorize if they want to reconnect. This does not revoke access on the provider side.

Parameters
$userId : string

A User identifier.

$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$organizationId : string|null = null

An Organization identifier. Optional parameter if the connection is scoped to an organization.

$options : RequestOptions|null = null
Tags
throws
WorkOSException

getUserConnectedAccount()

Get a connected account

public getUserConnectedAccount(string $userId, string $slug[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : ConnectedAccount

Retrieves a user's connected account for a specific provider.

Parameters
$userId : string

A User identifier.

$slug : string

The slug identifier of the provider (e.g., github, slack, notion).

$organizationId : string|null = null

An Organization identifier. Optional parameter if the connection is scoped to an organization.

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

listUserDataProviders()

List providers

public listUserDataProviders(string $userId[, string|null $organizationId = null ][, RequestOptions|null $options = null ]) : DataIntegrationsListResponse

Retrieves a list of available providers and the user's connection status for each. Returns all providers configured for your environment, along with the user's connected account information where applicable.

Parameters
$userId : string

A User identifier to list providers and connected accounts for.

$organizationId : string|null = null

An Organization identifier. Optional parameter to filter connections for a specific organization.

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

        
On this page

Search results