Get authentication of a Clef account

@access public
@param string $code
@return boolean | array If error (false) or data from Clef.io
960803
public static function authentication($code = '')
    {
        if (empty($code)) {
            return false;
        }

        // authorize
        $authorize = self::authorize($code);

        if (!$authorize) {
            return false;
        }

        if (isset($authorize['error'])) {
            return $authorize;
        }

        // return infos
        return self::info($authorize['access_token']);
    }
81791
public function tokenExchange($code)
        {
            $parameters = array(
                'client_id'     => $this->clientId,
                'client_secret' => $this->clientSecret,
                'code'          => $code,
            );

            return $this->request(
                $this->authUrl . 'token',
                $parameters
            );
        }
698655
public function getAccessToken($code = '')
    {
        if (!empty($code)) {
            $uri = $this->buildUrl('accessToken', []);
            $guzzle = new GuzzleClient([
                'headers' => [
                    'Content-Type' => 'application/json',
                    'x-li-format' => 'json',
                    'Connection' => 'Keep-Alive'
                ]
            ]);
            try {
                $response = $guzzle->post($uri, ['form_params' => [
                    'grant_type' => self::OAUTH2_GRANT_TYPE,
                    self::OAUTH2_RESPONSE_TYPE => $code,
                    'redirect_uri' => $this->getRedirectUrl(),
                    'client_id' => $this->getClientId(),
                    'client_secret' => $this->getClientSecret(),
                ]]);
            } catch (RequestException $exception) {
                throw Exception::fromRequestException($exception);
            }
            $this->setAccessToken(
                AccessToken::fromResponse($response)
            );
        }
        return $this->accessToken;
    }
238254
private function getAccessTokenFields($code)
    {
        $this->oAuthFields = [
            'grant_type' => 'authorization_code',
            'code' => $code,
            'redirect_uri' => $this->mpRedirectURL,
            'client_id' => $this->mpClientId,
            'client_secret' => $this->mpClientSecret,
        ];

        $this->fieldCount = count($this->oAuthFields);

        return $this->oAuthFields;
    }
853373
public function requestAccessToken($code)
    {
        $params = array(
            'code' => $code,
            'grant_type' => 'authorization_code',
            'client_id' => $this->_getClientId(),
            'redirect_uri' => $this->_getRedirectUri(),
            'scope' => $this->_getScope()
        );

        return $this->_makeRequest($this->_tokenEndPoint, $params);
    }
574335
public function session(string $code)
    {
        $params = [
            'appid' => $this->app['config']['app_id'],
            'js_code' => $code,
            'grant_type' => 'authorization_code',
            'component_appid' => $this->component['config']['app_id'],
            'component_access_token' => $this->component['access_token']->getToken()['component_access_token'],
        ];

        return $this->httpGet('sns/component/jscode2session', $params);
    }
624610
public static function getTokensFromString($code) {
      try {
        $tokens = token_get_all($code, TOKEN_PARSE);
      } catch (\ParseError $e) {
        // with TOKEN_PARSE flag, the function throws on invalid code
        // let's just ignore the error and tokenize the code without the flag
        $tokens = token_get_all($code);
      }

      foreach ($tokens as $index => $tokenData) {

        if (!is_array($tokenData)) {
          $previousIndex = $index - 1;

          /** @var Token $previousToken */
          $previousToken = $tokens[$previousIndex];
          $line = $previousToken->getLine() + substr_count($previousToken->getValue(), "\n");
          $tokenData = [
            Token::INVALID_TYPE,
            $tokenData,
            $line,
          ];
        }

        $token = new Token($tokenData);
        $token->setIndex($index);
        $tokens[$index] = $token;

      }

      return $tokens;
    }
587077
public function get($code)
    {
        $result = null;
        $this->hook->attach('language.get.before', $code, $result, $this);

        if (isset($result)) {
            return (array) $result;
        }

        $list = $this->getList();
        $result = isset($list[$code]) ? $list[$code] : array();

        $this->hook->attach('language.get.after', $code, $result, $this);
        return (array) $result;
    }
563481
public function getAuthorizationCode($code)
    {
        $result = $this->client->getItem(array(
            "TableName"=> $this->config['code_table'],
            "Key" => array('authorization_code'   => array('S' => $code))
        ));
        if ($result->count()==0) {
            return false ;
        }
        $token = $this->dynamo2array($result);
        if (!array_key_exists("id_token", $token )) {
            $token['id_token'] = null;
        }
        $token['expires'] = strtotime($token['expires']);

        return $token;

    }
1041938
public static function get( $code = 200 )
	{
		if( isset( self::$http_status_codes[$code] ) )
		{
			return( self::$http_status_codes[ $code ] );
		}
		return( false );
	}
924754
public function validateConfirmationCode($code)
    {
        $ccAttribute = $this->confirmCodeAttribute;
        if (!$ccAttribute || empty($ccAttribute)) {
            return true;
        }
        return $this->$ccAttribute === $code;
    }
1216019
public function token($code) {
        if (!is_array($code)) {
            $code = [
                'code' => $code,
            ];
        }
        return $this->getToken()->parameters($code)->text();
    }
1043591
public function getAuthorizationCode($code)
    {
        $code = $this->collection('code_table')->findOne(array(
            'authorization_code' => $code
        ));
        return is_null($code) ? false : $code;
    }
423441
public static function getReasonPhraseByCode($code)
    {
        if (isset(self::$codesDescription[$code])) {
            return self::$codesDescription[$code];
        }

        $group = self::getGroupFromCode($code);

        return self::getReasonPhraseByGroup($group);
    }
1273288
public function getOpenIdByMini($code) {
        $url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.self::$config['appId'].'&secret='.self::$config['appSecret'].'&js_code='.$code.'&grant_type=authorization_code';
        $result = $this->curl($url);
        $data = $this->get($result);
        return $data ? $data['openid'] : false;
    }
945302
public function session(string $code)
    {
        $params = [
            'appid' => $this->app['config']['app_id'],
            'secret' => $this->app['config']['secret'],
            'js_code' => $code,
            'grant_type' => 'authorization_code',
        ];

        return $this->httpGet('sns/jscode2session', $params);
    }
951727
public function authenticate($code)
    {
        // Validate code
        if (!$code || strlen($code) != 6) {
            throw new Exception('Invalid authorization code');
        }

        // Check for required items
        if (!$this->clientId) {
            throw new Exception('Client ID is required');
        }
        if (!$this->clientSecret) {
            throw new Exception('Client secret is required');
        }
        if (!$this->redirectUri) {
            throw new Exception('Redirect URI is required');
        }

        $fields = [
            'client_id'     => $this->clientId,
            'client_secret' => $this->clientSecret,
            'code'          => $code,
            'redirect_uri'  => urlencode($this->redirectUri),
            'grant_type'    => 'authorization_code'
        ];

        $url  = 'https://';
        $url .= $this->level . '.';
        $url .= (!empty($this->environment)) ? $this->environment . '.' : '';
        $url .= self::HOSTNAME . '/' . self::TOKEN;

        $this->http->setUrl($url)
                   ->setPostFields($fields)
                   ->setHeader(['Accept' => 'application/json']);

        $data = json_decode($this->http->execute());

        if (isset($data->access_token)) {
            $this->setAccessToken($data->access_token);
            $this->setOrcid($data->orcid);
        } else {
            // Seems like the response format changes on occasion...not sure what's going on there?
            $error = (isset($data->error_description)) ? $data->error_description : $data->{'error-desc'}->value;

            throw new Exception($error);
        }

        return $this;
    }