PHP Class Auth0\SDK\API\Oauth2Client

Author: Auth0
Show file Open project: auth0/auth0-php

Public Properties

Property Type Description
$URL_MAP array Auth0 URL Map.
$persistantMap array Available keys to persist data.

Protected Properties

Property Type Description
$access_token string NULL means that there is no authorization yet.
$client_id string Auth0 Client ID
$client_secret string Auth0 Client Secret
$debug_mode boolean Debug mode flag.
$debugger Closure Will be called only if $debug_mode is true.
$domain string Auth0 Domain.
$oauth_client OAuth2\Client OAuth2 Client.
$redirect_uri string Redirect URI needed on OAuth2 requests.
$refresh_token string Auth0 Refresh Token
$user string The user object

Public Methods

Method Description
__construct ( array $config ) BaseAuth0 Constructor.
checkRequirements ( ) Checks for all dependencies of SDK or API.
debugInfo ( mixed $info ) If debug mode is set, sends $info to debugger \Closure.
deleteAllPersistentData ( ) Deletes all persistent data, for every mapped key.
exchangeCode ( ) : boolean Exchanges the code from the URI parameters for an access token, id token and user info
getAccessToken ( ) : string Gets $access_token.
getAppMetadata ( )
getClientId ( ) : string Gets $client_id.
getClientSecret ( ) : string Gets $client_secret.
getDebugMode ( ) : boolean Gets $debug_mode.
getDebugger ( ) : Closure Gets $debugger.
getDomain ( ) : string Gets $domain
getIdToken ( ) : string Gets the id token
getRedirectUri ( ) : string Gets $redirect_uri.
getRefreshToken ( ) : string Gets $refresh_token.
getUser ( ) : array Requests user info to Auth0 server.
getUserMetadata ( )
logout ( ) Logout (removes all persisten data)
setAccessToken ( string $access_token ) : Auth0\SDK\BaseAuth0 Sets and persists $access_token.
setClientId ( string $client_id ) : Auth0\SDK\BaseAuth0 Sets $client_id.
setClientSecret ( string $client_secret ) : Auth0\SDK\BaseAuth0 Sets $client_secret.
setDebugMode ( boolean $debug_mode ) : Auth0\SDK\BaseAuth0 Sets $debug_mode.
setDebugger ( Closure $debugger ) : Auth0\SDK\BaseAuth0 Sets $debugger.
setDomain ( string $domain ) : Auth0\SDK\BaseAuth0 Sets $domain.
setIdToken ( string $id_token ) : Auth0\SDK\BaseAuth0 Sets and persists $id_token.
setRedirectUri ( string $redirect_uri ) : Auth0\SDK\BaseAuth0 Sets $redirect_uri.
setRefreshToken ( string $refresh_token ) : Auth0\SDK\BaseAuth0 Sets and persists $refresh_token.
setUser ( $user )
updateUserMetadata ( $metadata ) : User Updathes the user metadata. This end up calling the path /users/{id_user} To delete an attribute, just set it null. ie: [ 'old_attr' => null ] It will only update the existing attrs and keep the others untouch for more info: https://auth0.com/docs/apiv2#!/users/patch_users_by_id

Protected Methods

Method Description
generateUrl ( string $domain_key, string $path = '/' ) : string Constructs an API URL.

Private Methods

Method Description
dontPersist ( String $name ) Removes $name from the persistantMap, thus not persisting it when we set the value

Method Details

__construct() public method

Configuration: - domain (String) Required. Should match your Auth0 domain - client_id (String) Required. The id of the application, you can get this in the auth0 console - client_secret (String) Required. The application secret, same comment as above - redirect_uri (String) Required. The uri of the auth callback, used as a security method - persist_user (Boolean) Optional. Indicates if you want to persist the user info, default true - persist_access_token (Boolean) Optional. Indicates if you want to persist the access token, default false - persist_refresh_token (Boolean) Optional. Indicates if you want to persist the refresh token, default false - persist_id_token (Boolean) Optional. Indicates if you want to persist the id token, default false - store (Mixed) Optional. Indicates how we store the persisting methods, default is session store, you can pass false to avoid storing it or a class that implements a store (get, set, delete). TODO: add a proper interface - debug (Boolean) Optional. Default false
public __construct ( array $config )
$config array Required

checkRequirements() final public method

Checks for all dependencies of SDK or API.
final public checkRequirements ( )

debugInfo() public method

If debug mode is set, sends $info to debugger \Closure.
public debugInfo ( mixed $info )
$info mixed Info to debug. It will be converted to string.

deleteAllPersistentData() public method

Deletes all persistent data, for every mapped key.

exchangeCode() public method

Exchanges the code from the URI parameters for an access token, id token and user info
public exchangeCode ( ) : boolean
return boolean Whether it exchanged the code or not correctly

generateUrl() final protected method

Constructs an API URL.
final protected generateUrl ( string $domain_key, string $path = '/' ) : string
$domain_key string
$path string
return string

getAccessToken() final public method

Gets $access_token.
final public getAccessToken ( ) : string
return string

getAppMetadata() public method

public getAppMetadata ( )

getClientId() final public method

Gets $client_id.
final public getClientId ( ) : string
return string

getClientSecret() final public method

Gets $client_secret.
final public getClientSecret ( ) : string
return string

getDebugMode() final public method

Gets $debug_mode.
final public getDebugMode ( ) : boolean
return boolean

getDebugger() final public method

Gets $debugger.
final public getDebugger ( ) : Closure
return Closure

getDomain() final public method

Gets $domain
final public getDomain ( ) : string
return string

getIdToken() final public method

Gets the id token
final public getIdToken ( ) : string
return string

getRedirectUri() final public method

Gets $redirect_uri.
final public getRedirectUri ( ) : string
return string

getRefreshToken() final public method

Gets $refresh_token.
final public getRefreshToken ( ) : string
return string

getUser() public method

Requests user info to Auth0 server.
public getUser ( ) : array
return array

getUserMetadata() public method

public getUserMetadata ( )

logout() final public method

Logout (removes all persisten data)
final public logout ( )

setAccessToken() public method

Sets and persists $access_token.
public setAccessToken ( string $access_token ) : Auth0\SDK\BaseAuth0
$access_token string
return Auth0\SDK\BaseAuth0

setClientId() final public method

Sets $client_id.
final public setClientId ( string $client_id ) : Auth0\SDK\BaseAuth0
$client_id string
return Auth0\SDK\BaseAuth0

setClientSecret() final public method

Sets $client_secret.
final public setClientSecret ( string $client_secret ) : Auth0\SDK\BaseAuth0
$client_secret string
return Auth0\SDK\BaseAuth0

setDebugMode() final public method

Sets $debug_mode.
final public setDebugMode ( boolean $debug_mode ) : Auth0\SDK\BaseAuth0
$debug_mode boolean
return Auth0\SDK\BaseAuth0

setDebugger() final public method

Sets $debugger.
final public setDebugger ( Closure $debugger ) : Auth0\SDK\BaseAuth0
$debugger Closure
return Auth0\SDK\BaseAuth0

setDomain() final public method

Sets $domain.
final public setDomain ( string $domain ) : Auth0\SDK\BaseAuth0
$domain string
return Auth0\SDK\BaseAuth0

setIdToken() public method

Sets and persists $id_token.
public setIdToken ( string $id_token ) : Auth0\SDK\BaseAuth0
$id_token string
return Auth0\SDK\BaseAuth0

setRedirectUri() final public method

Sets $redirect_uri.
final public setRedirectUri ( string $redirect_uri ) : Auth0\SDK\BaseAuth0
$redirect_uri string
return Auth0\SDK\BaseAuth0

setRefreshToken() public method

Sets and persists $refresh_token.
public setRefreshToken ( string $refresh_token ) : Auth0\SDK\BaseAuth0
$refresh_token string
return Auth0\SDK\BaseAuth0

setUser() public method

public setUser ( $user )

updateUserMetadata() public method

Updathes the user metadata. This end up calling the path /users/{id_user} To delete an attribute, just set it null. ie: [ 'old_attr' => null ] It will only update the existing attrs and keep the others untouch for more info: https://auth0.com/docs/apiv2#!/users/patch_users_by_id
public updateUserMetadata ( $metadata ) : User
return User data

Property Details

$URL_MAP public static property

Auth0 URL Map.
public static array $URL_MAP
return array

$access_token protected property

NULL means that there is no authorization yet.
protected string $access_token
return string

$client_id protected property

Auth0 Client ID
protected string $client_id
return string

$client_secret protected property

Auth0 Client Secret
protected string $client_secret
return string

$debug_mode protected property

Debug mode flag.
protected bool $debug_mode
return boolean

$debugger protected property

Will be called only if $debug_mode is true.
protected Closure $debugger
return Closure

$domain protected property

Auth0 Domain.
protected string $domain
return string

$oauth_client protected property

OAuth2 Client.
protected Client,OAuth2 $oauth_client
return OAuth2\Client

$persistantMap public property

Available keys to persist data.
public array $persistantMap
return array

$redirect_uri protected property

Redirect URI needed on OAuth2 requests.
protected string $redirect_uri
return string

$refresh_token protected property

Auth0 Refresh Token
protected string $refresh_token
return string

$user protected property

The user object
protected string $user
return string