CRM_OAuth_Hook
in package
Table of Contents
Methods
- oauthProviders() : void
- Generate a list of available OAuth providers.
- oauthReturn() : void
- Fires whenever a user returns to our site (from a successful AuthCode flow).
- oauthReturnError() : void
- Fires whenever a user returns to our site (from an unsuccessful AuthCode flow).
- oauthToken() : void
- Fires a hook whenever we receive an updated OAuth token.
Methods
oauthProviders()
Generate a list of available OAuth providers.
public
static oauthProviders(array<string|int, mixed> &$providers) : void
Parameters
- $providers : array<string|int, mixed>
-
Alterable list of providers, keyed by symbolic name. Each has these properties:
- name: string (MUST match the key in the array)
- class: string, the controller class which generates and sends token requests (default: CiviGenericProvider)
- options: array, constructor arguments for the driver class. Typical properties are:
- urlAuthorize: string (e.g. "https://api.example.com/auth")
- urlAccessToken: string (e.g. "https://api.example.com/token")
- urlResourceOwnerDetails: string (e.g. "https://api.example.com/owner")
- scopes: array (e.g. "read_profile", "frobnicate_widgets")
- responseModes: array (e.g. "query", "web_message")
- tags: string[], list of free-tags describing the purpose/behavior of this provider
oauthReturn()
Fires whenever a user returns to our site (from a successful AuthCode flow).
public
static oauthReturn(array<string|int, mixed> $tokenRecord, string|null &$nextUrl) : void
Parameters
- $tokenRecord : array<string|int, mixed>
-
The newly created token record (e.g OAuthSysToken or OAuthContactToken)
- $nextUrl : string|null
-
When the user returns from an OAuth provider, we can redirect them to an internal page. This alterable string identifies the next page.
oauthReturnError()
Fires whenever a user returns to our site (from an unsuccessful AuthCode flow).
public
static oauthReturnError(string|null $error, string|null $description, string|null $uri, string $state) : void
Parameters
- $error : string|null
- $description : string|null
- $uri : string|null
- $state : string
oauthToken()
Fires a hook whenever we receive an updated OAuth token.
public
static oauthToken(string $flow, string $type, array<string|int, mixed> &$token) : void
Parameters
- $flow : string
-
Ex: 'init' or 'refresh'
- $type : string
-
Ex: 'OAuthSysToken', 'OAuthContactToken', 'OAuthSessionToken'
- $token : array<string|int, mixed>
-
Ex: ['tag' => 'foo', 'client_id' => 123]
The following fields are equally applicable to all storage-types:
- access_token
- client_id
- expires
- grant_type
- raw
- refresh_token
- resource_owner
- resource_owner_name
- scopes
- tag
- token_type
Some fields depend on the storage-type:
- id (OAuthSysToken, OAuthContactToken)
- contact_id (OAuthContactToken)
- cardinal (OAuthSessionToken)
- created_date (extant records; OAuthSysToken, OAuthContactToken)
- modified_date (extant records; OAuthSysToken, OAuthContactToken)