Add custom fields to your Bearer Token response here, then override
AuthorizationServer::getResponseType() to pull in your version of
this class rather than the default.

@param AccessTokenEntityInterface $accessToken
@return array
760465
protected function getExtraParams(AccessTokenEntityInterface $accessToken)
    {

        $user = User::where( 'id', $accessToken->getUserIdentifier() )->first();

        if ( $user->ehr_pid &&
            $user->connection ) {
            $patientRepo = new PatientRepository();
            $patientRepo->setConnection( $user->connection );
            $patient = $patientRepo->findByPid( $user->ehr_pid );
            if ( $patient->getStatus() == 'active' ) {
                $user->activeLoginCount = $user->activeLoginCount + 1;
            }
        }

        $user->loginCount = $user->loginCount + 1;
        $user->save();

        // Custom parameters for /signin can be added here
        $response = ['firstTimeLogin' => 0 ];
        if ( $user->loginCount == 1 ) {
            $response = ['firstTimeLogin' => 1 ];
        }

        $response = ['firstTimeLoginActive' => 0 ];
        if ( $user->activeLoginCount == 1 ) {
            $response = ['firstTimeLoginActive' => 1 ];
        }

        return $response;
    }
827969
public function send(EncodedPayload $payload, $accessToken)
    {
        if (empty($this->fluentLogger)) {
            $this->loadFluentLogger();
        }

        $scrubbedPayload = $payload->data();
        
        $success = $this->fluentLogger->post($this->fluentTag, $scrubbedPayload);
        $status = $success ? 200 : 400;
        $info = $success ? 'OK' : 'Bad Request';
        $uuid = $scrubbedPayload['data']['uuid'];

        return new Response($status, $info, $uuid);
    }
725699
public function withAccessToken (AccessToken $token)
    {
        $config = $this->getConfig();
        $this->configureHandlers($config['handler']);
        
        $config['wechat.accessToken'] = $token;
        $config['wechat.developerMode'] = $this->developerMode;
        
        return new static($config);
    }
257223
public function setAccessToken($accessToken)
    {
        if (in_array('access_token', $this->persistantMap)) {
            $this->store->set('access_token', $accessToken);
        }

        $this->accessToken = $accessToken;
        return $this;
    }
637975
public function connect($accessToken = null)
	{
		if (is_null($accessToken))
		{
			return $this->getRedirectLoginHelper();
		}
		else
		{
			return $this->getFacebookSession($accessToken);
		}
	}
706627
protected function prepareTokenResponse(
        AccessToken $accessToken,
        RefreshToken $refreshToken = null,
        bool $useRefreshTokenScopes = false
    ): ResponseInterface {
        $owner = $accessToken->getOwner();
        $scopes = $useRefreshTokenScopes ? $refreshToken->getScopes() : $accessToken->getScopes();

        $responseBody = [
            'access_token' => $accessToken->getToken(),
            'token_type' => 'Bearer',
            'expires_in' => $accessToken->getExpiresIn(),
            'scope' => implode(' ', $scopes),
            'owner_id' => $owner ? $owner->getTokenOwnerId() : null,
        ];

        if (null !== $refreshToken) {
            $responseBody['refresh_token'] = $refreshToken->getToken();
        }

        return new Response\JsonResponse(array_filter($responseBody));
    }
28334
protected function parseTokenResponse(ResponseInterface $response):AccessToken{
		$data = Psr7\get_json($response, true);

		if(!$data || !is_array($data)){
			throw new ProviderException('unable to parse token response');
		}
		elseif(isset($data['error'])){
			throw new ProviderException('error retrieving access token: '.$data['message']);
		}
		elseif(!isset($data['session']['key'])){
			throw new ProviderException('token missing');
		}

		$token = new AccessToken([
			'provider'    => $this->serviceName,
			'accessToken' => $data['session']['key'],
			'expires'     => AccessToken::EOL_NEVER_EXPIRES,
		]);

		unset($data['session']['key']);

		$token->extraParams = $data;

		$this->storage->storeAccessToken($this->serviceName, $token);

		return $token;
	}
84930
public function setAccessToken(AccessToken $accessToken)
    {
        $this->accessToken = $accessToken;

        if ($this->tokenUpdatedCallback) {
            call_user_func($this->tokenUpdatedCallback, $accessToken);
        }
    }
144956
public function setDefaultAccessToken($accessToken)
    {
        if (is_string($accessToken)) {
            $this->defaultAccessToken = new AccessToken($accessToken);
        }
        if ($accessToken instanceof AccessToken) {
            $this->defaultAccessToken = $accessToken;
        }

       // throw new \InvalidArgumentException('Токен ключ по умолчанию должен быть типа string или \Steein\SDK\Authentication\AccessToken');
    }
544434
protected function _getUserData(Zend_Oauth_Token_Access $accessToken) {
        $authVars = $this->_getAuthVars();

        $token = $accessToken->getToken();
        $tokenSecret = $accessToken->getTokenSecret();
        $vimeoService = new Garp_Service_Vimeo_Pro(
            $authVars->consumerKey,
            $authVars->consumerSecret,
            $token,
            $tokenSecret
        );
        $userDataFromVimeo = $vimeoService->people->getInfo($token);
        $id = $userDataFromVimeo['id'];

        $ini = Zend_Registry::get('config');
        $sessionColumns = Zend_Db_Select::SQL_WILDCARD;
        if (!empty($ini->auth->login->sessionColumns)) {
            $sessionColumns = $ini->auth->login->sessionColumns;
            $sessionColumns = explode(',', $sessionColumns);
        }
        $userModel = new Model_User();
        $userConditions = $userModel->select()->from($userModel->getName(), $sessionColumns);

        $model = new Model_AuthVimeo();
        $model->bindModel('Model_User', array('conditions' => $userConditions));
        $userData = $model->fetchRow(
            $model->select()
                  ->where('vimeo_id = ?', $id)
        );
        if (!$userData || !$userData->Model_User) {
            $userData = $model->createNew(
                $id,
                $accessToken,
                $this->_mapProperties($userDataFromVimeo)
            );
        } else {
            $model->getObserver('Authenticatable')->updateLoginStats($userData->user_id);
            $userData = $userData->Model_User;
        }
        return $userData;
    }
658472
protected function fetchResourceOwnerDetails(AccessToken $token)
    {
        $url = $this->getResourceOwnerDetailsUrl($token);

        $request = $this->getAuthenticatedRequest(self::METHOD_POST, $url, $token);

        return $this->getParsedResponse($request);
    }
1233088
public function getAccessToken()
    {
        try {
            $response = $this->post('/oauth/token')->send();
        } catch (ClientErrorResponseException $e) {
            throw OauthException::factory($e->getRequest(), $e->getResponse());
        }
        return new AccessToken($this, $response);
    }
704045
public function verifyAccessToken($accessToken)
    {
        $jwtPayload = $this->decodeAccessToken($accessToken);

        $expectedIss = sprintf('https://cognito-idp.%s.amazonaws.com/%s', $this->region, $this->userPoolId);
        if ($jwtPayload['iss'] !== $expectedIss) {
            throw new TokenVerificationException('invalid iss');
        }

        if ($jwtPayload['token_use'] !== 'access') {
            throw new TokenVerificationException('invalid token_use');
        }

        if ($jwtPayload['exp'] < time()) {
            throw new TokenExpiryException('invalid exp');
        }

        return $jwtPayload['username'];
    }
362148
public function getUser($accessToken = null, array $options = [])
    {
        if (null === $accessToken) {
            $options['access_token'] = $this->blizzardClient->getAccessToken();
        } else {
            $options['access_token'] = $accessToken;
        }

        return $this->request('/account/user', $options);
    }
521541
public function getResourceOwner(AccessToken $token)
    {
        try {
            /** @noinspection PhpIncompatibleReturnTypeInspection */
            return parent::getResourceOwner($token);
        } catch (IdentityProviderException $err) {
            if ($err->getCode() === 404) {
                throw new UserNotPresentException($err->getCode(), $err->getResponseBody());
            }
            throw $err;
        }
    }
342070
private function getFacebookSession($accessToken)
	{
		$facebookSession = new FacebookSession($accessToken);

		try 
		{
		  $facebookSession->validate();

		  return $facebookSession;
		} 
		catch (FacebookRequestException $ex)
		{
			throw new FacebookException($ex->getMessage());
		}
		catch (\Exception $ex) 
		{
			throw new FacebookException($ex->getMessage());
		}
	}
1228606
public function setAccessToken(AccessToken $token)
    {
        $this->container->get('config')
            ->set('access_token', json_encode($token->jsonSerialize()));
    }