class OAuthClient

Class OAuthClient

Constants

GENERAL_ADMIN_MODE

will be saved as user_id in oauth_access dbtable

Properties

protected string $clientId

The application's Client ID.

protected string $clientSecret

The application's Client Secret.

protected string $redirectUrl

The URL to which Auth will redirect the browser after authorization has been granted by the user.

protected string $authorizeUrl

The Authorization Endpoint performs Authentication of the End-User.

protected string $accessTokenUrl

To obtain an Access Token, an ID Token, and optionally a Refresh Token, the RP (Client) sends a Token Request to the Token Endpoint to obtain a Token Response

protected string $endSessionUrl

A URL where you can end a session by revoking an access_token.

protected string $scope

The scopes which you want to request authorization for.

protected string $state

An opaque value the application adds to the initial request that Auth includes when redirecting back to the application.

protected AccessToken $accessToken

Access token Object representing string like accessToken an authorization issued to the client refreshToken see refreshToken

protected string $refreshToken

Refresh tokens are issued to the client by the authorization server and are used to obtain a new access token when the current access token becomes invalid or expires

protected int $expires

The lifetime in seconds of the access token

protected string $code

The authorization code received from the authorization server

protected $resourceOwner
protected bool $isPersonal

false = Admin has created account

Methods

__construct(string $clientId = null, string $clientSecret = null, string $redirectUrl = null)

OAuthClient constructor.

addScope($scope)

Adds a new scope to the existing scopes.

disconnect(string $redirect_url)

Logout

fromArray(array $data)

No description

AccessToken
getAccessToken()

Function to test connection directly to an oauth server

string
getAccessTokenAsString()

No description

mixed
getAccessTokenUrl()

No description

mixed
getAuthorizeUrl()

No description

string
getClientId()

Get application's Client ID.

string
getClientSecret()

Get application's Client Secret

string
getCode()

No description

string
getEndSessionUrl()

No description

int
getExpires()

No description

string
getPostLogoutRedirectUrl(string $redirect_url)

No description

mixed
getRedirectUrl()

No description

string
getRefreshToken()

No description

string
getScope()

No description

array
getScopeArray()

Returns the scope as array.

string
getState()

No description

int
hasExpired()

No description

bool
isConnected()

Prove connection within xelos intranet to avoid to much request to an oauth server

bool
isPersonal()

No description

bool
isSendBasicAuthorization()

No description

bool
processAuthorizationCodeResponse(string $code)

Process Authorization Code Grant

processOpenIDConfiguration(OpenIDConfiguration $config)

Use an OpenID Configuration to setup this OAuth client

AccessToken|null
refreshAccessToken()

Returns the access token or null if there is no token yet.

setAccessToken(AccessToken $token = null)

No description

setAccessTokenUrl(mixed $accessTokenUrl)

No description

setAuthorizeUrl(mixed $authorizeUrl)

No description

setClientId(string $clientId)

Set application's Client ID.

setClientSecret(mixed $clientSecret)

Set application's Client Secret

$this
setEndSessionUrl($endSessionEndpoint)

No description

setOptionalAuthParams(array $params)

No description

setPKCEParams(string $codeVerifier, string $codeChallengeMethod = 'S256')

Set Code Verifier and Code Challenge Method for RFC 7636: Proof Key for Code Exchange (PKCE) which is an alternative to client_secret or may be used in hybrid flows

setPersonal(bool $isPersonal = true)

Defines whether the client is for personal or global usage.

setRedirectUrl(mixed $redirectUrl)

No description

setRefreshToken(string $token)

No description

setResource($resource = null)

Set additional resource param when requesting access code

setScope(string $scope)

Set scopes which you want to request authorization for.

void
setSendBasicAuthorization(bool $sendBasicAuthorization = true)

Should client_id and client_secret be sent as Basic Auth Header during code exchange?

setState(string $state)

No description

startAuthorisationCodeFlow()

Start Authorization Code Grant flow (redirect to authorizeUrl)

array
toArray()

No description

Details

at line 164
__construct(string $clientId = null, string $clientSecret = null, string $redirectUrl = null)

OAuthClient constructor.

Parameters

string $clientId

The application's Client ID.

string $clientSecret

The application's Client Secret.

string $redirectUrl

The URL to which Auth will redirect the browser after authorization has been granted by the user. Will default to webservice OAuth Endpoint

at line 311
OAuthClient addScope($scope)

Adds a new scope to the existing scopes.

Parameters

$scope

Return Value

OAuthClient

at line 388
disconnect(string $redirect_url)

Logout

Parameters

string $redirect_url

Exceptions

Exception

at line 685
OAuthClient fromArray(array $data)

No description

Parameters

array $data

Return Value

OAuthClient

at line 473
protected AccessToken getAccessToken()

internal  
 

Function to test connection directly to an oauth server

Return Value

AccessToken

at line 485
string getAccessTokenAsString()

No description

Return Value

string

Exceptions

IdentityProviderException

at line 261
mixed getAccessTokenUrl()

No description

Return Value

mixed

at line 244
mixed getAuthorizeUrl()

No description

Return Value

mixed

at line 187
string getClientId()

Get application's Client ID.

Return Value

string

at line 208
string getClientSecret()

Get application's Client Secret

Return Value

string

at line 377
string getCode()

No description

Return Value

string

at line 407
string getEndSessionUrl()

No description

Return Value

string

at line 363
int getExpires()

No description

Return Value

int

at line 399
string getPostLogoutRedirectUrl(string $redirect_url)

No description

Parameters

string $redirect_url

Return Value

string

at line 227
mixed getRedirectUrl()

No description

Return Value

mixed

at line 346
string getRefreshToken()

No description

Return Value

string

at line 278
string getScope()

No description

Return Value

string

at line 300
array getScopeArray()

Returns the scope as array.

Return Value

array

at line 329
string getState()

No description

Return Value

string

at line 370
int hasExpired()

No description

Return Value

int

at line 428
bool isConnected()

Prove connection within xelos intranet to avoid to much request to an oauth server

Return Value

bool

Exceptions

IdentityProviderException

at line 511
bool isPersonal()

No description

Return Value

bool

at line 743
bool isSendBasicAuthorization()

No description

Return Value

bool

at line 557
bool processAuthorizationCodeResponse(string $code)

Process Authorization Code Grant

Parameters

string $code

Authorization Code

Return Value

bool

at line 176
processOpenIDConfiguration(OpenIDConfiguration $config)

Use an OpenID Configuration to setup this OAuth client

Parameters

OpenIDConfiguration $config

at line 443
AccessToken|null refreshAccessToken()

Returns the access token or null if there is no token yet.

If there is a token and the token is expired, it will automatically request a new access token by using the refresh token.

Return Value

AccessToken|null

Exceptions

IdentityProviderException

//League does not reveal Exceptions in their comments

at line 498
OAuthClient setAccessToken(AccessToken $token = null)

No description

Parameters

AccessToken $token

Return Value

OAuthClient

at line 270
OAuthClient setAccessTokenUrl(mixed $accessTokenUrl)

No description

Parameters

mixed $accessTokenUrl

Return Value

OAuthClient

at line 253
OAuthClient setAuthorizeUrl(mixed $authorizeUrl)

No description

Parameters

mixed $authorizeUrl

Return Value

OAuthClient

at line 199
OAuthClient setClientId(string $clientId)

Set application's Client ID.

Find this value at your Application's Settings.

Parameters

string $clientId

Return Value

OAuthClient

at line 219
OAuthClient setClientSecret(mixed $clientSecret)

Set application's Client Secret

Parameters

mixed $clientSecret

Return Value

OAuthClient

at line 416
$this setEndSessionUrl($endSessionEndpoint)

No description

Parameters

$endSessionEndpoint

Return Value

$this

at line 321
OAuthClient setOptionalAuthParams(array $params)

No description

Parameters

array $params

Return Value

OAuthClient

at line 761
setPKCEParams(string $codeVerifier, string $codeChallengeMethod = 'S256')

Set Code Verifier and Code Challenge Method for RFC 7636: Proof Key for Code Exchange (PKCE) which is an alternative to client_secret or may be used in hybrid flows

Parameters

string $codeVerifier

Empty will disable PKCE for the process/client

string $codeChallengeMethod

at line 522
OAuthClient setPersonal(bool $isPersonal = true)

Defines whether the client is for personal or global usage.

Parameters

bool $isPersonal

Return Value

OAuthClient

at line 236
OAuthClient setRedirectUrl(mixed $redirectUrl)

No description

Parameters

mixed $redirectUrl

Return Value

OAuthClient

at line 355
OAuthClient setRefreshToken(string $token)

No description

Parameters

string $token

Return Value

OAuthClient

at line 736
setResource($resource = null)

Set additional resource param when requesting access code

Parameters

$resource

at line 290
OAuthClient setScope(string $scope)

Set scopes which you want to request authorization for.

These must be separated by a space.

Parameters

string $scope

Return Value

OAuthClient

at line 751
void setSendBasicAuthorization(bool $sendBasicAuthorization = true)

Should client_id and client_secret be sent as Basic Auth Header during code exchange?

Parameters

bool $sendBasicAuthorization

Return Value

void

at line 338
OAuthClient setState(string $state)

No description

Parameters

string $state

Return Value

OAuthClient

at line 531
startAuthorisationCodeFlow()

Start Authorization Code Grant flow (redirect to authorizeUrl)

Exceptions

Exception

at line 634
array toArray()

No description

Return Value

array