Auth0\SDK\API\Oauth2Client::__construct PHP Метод

__construct() публичный Метод

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
    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);
        }
    }