public function Oauth2Client::__construct in Auth0 Single Sign On 8.2
BaseAuth0 Constructor.
Parameters
array $config Required:
Throws
CoreException If `domain` is not provided.
CoreException If `client_id` is not provided.
CoreException If `client_secret` is not provided.
CoreException If `redirect_uri` is not provided.
Deprecated
5.2.1, use \Auth0\SDK\Auth0 instead.
Configuration:
- domain (String) - Required. Should match your Auth0 domain
- client_id (String) - Required. Client ID, found in Application > Settings in the Auth0 dashboard.
- client_secret (String) - Required. Client Secret, found in Application > Settings in the Auth0 dashboard.
- 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. True to, persist the access token; default false
- persist_refresh_token (Boolean) - Optional. True 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).
- debug (Boolean) - Optional. Default false
File
- vendor/
auth0/ auth0-php/ src/ API/ Oauth2Client.php, line 156
Class
- Oauth2Client
- This class provides access to Auth0 Platform.
Namespace
Auth0\SDK\APICode
public function __construct(array $config) {
// check for system requirements
$this
->checkRequirements();
// now we are ready to go on...
if (isset($config['domain'])) {
$this->domain = $config['domain'];
}
else {
throw new CoreException('Invalid domain');
}
if (isset($config['client_id'])) {
$this->client_id = $config['client_id'];
}
else {
throw new CoreException('Invalid client_id');
}
if (isset($config['client_secret'])) {
$this->client_secret = $config['client_secret'];
}
else {
throw new CoreException('Invalid client_secret');
}
if (isset($config['redirect_uri'])) {
$this->redirect_uri = $config['redirect_uri'];
}
else {
throw new CoreException('Invalid redirect_uri');
}
if (isset($config['debug'])) {
$this->debug_mode = $config['debug'];
}
else {
$this->debug_mode = false;
}
// User info is persisted unless said otherwise
if (isset($config['persist_user']) && $config['persist_user'] === false) {
$this
->dontPersist('user');
}
// Access token is not persisted unless said otherwise
if (!isset($config['persist_access_token']) || isset($config['persist_access_token']) && $config['persist_access_token'] === false) {
$this
->dontPersist('access_token');
}
// Refresh token is not persisted unless said otherwise
if (!isset($config['persist_refresh_token']) || isset($config['persist_refresh_token']) && $config['persist_refresh_token'] === false) {
$this
->dontPersist('refresh_token');
}
// Id token is not per persisted unless said otherwise
if (!isset($config['persist_id_token']) || isset($config['persist_id_token']) && $config['persist_id_token'] === false) {
$this
->dontPersist('id_token');
}
if (isset($config['store'])) {
if ($config['store'] === false) {
$this->store = new EmptyStore();
}
else {
$this->store = $config['store'];
}
}
else {
$this->store = new SessionStore();
}
$this->oauth_client = new Client($this->client_id, $this->client_secret);
$this->user = $this->store
->get('user');
$this->access_token = $this->store
->get('access_token');
$this->id_token = $this->store
->get('id_token');
$this->refresh_token = $this->store
->get('refresh_token');
if (!$this->access_token) {
$this->oauth_client
->setAccessToken($this->access_token);
}
}