public function convertToJWT(CryptKey $privateKey)
    {
        $tokenBuilder = (new Builder())
            ->setAudience($this->getClient()->getIdentifier())
            ->setId($this->getIdentifier(), true)
            ->setIssuedAt(time())
            ->setNotBefore(time())
            ->setExpiration($this->getExpiryDateTime()->getTimestamp())
            ->setSubject($this->getUserIdentifier())
            ->set('scopes', $this->getScopes());

        // add user name to claims
        if ($this->getUserIdentifier()) {
            $userEntity = $this->getUserEntity();
            $member = $userEntity->getMember();

            $tokenBuilder->set('fn', $member ? $member->FirstName : null)
                ->set('ln', $member ? $member->Surname : null);
        }

        return $tokenBuilder->sign(new Sha256(), new Key($privateKey->getKeyPath(), $privateKey->getPassPhrase()))
            ->getToken();
    }
public function convertToJWT(CryptKey $privateKey)
    {
        $tokenBuilder = (new Builder())
            ->setAudience($this->getClient()->getIdentifier())
            ->setId($this->getIdentifier(), true)
            ->setIssuedAt(time())
            ->setNotBefore(time())
            ->setExpiration($this->getExpiryDateTime()->getTimestamp())
            ->setSubject($this->getUserIdentifier())
            ->set('scopes', $this->getScopes());

        // add user name to claims
        if ($this->getUserIdentifier()) {
            $userEntity = $this->getUserEntity();
            $member = $userEntity->getMember();

            $tokenBuilder->set('fn', $member ? $member->FirstName : null)
                ->set('ln', $member ? $member->Surname : null);
        }

        return $tokenBuilder->sign(new Sha256(), new Key($privateKey->getKeyPath(), $privateKey->getPassPhrase()))
            ->getToken();
    }
public function convertToJWT ( CryptKey $ privateKey ) { $ tokenBuilder = ( new Builder ( ) ) -> setAudience ( $ this -> getClient ( ) -> getIdentifier ( ) ) -> setId ( $ this -> getIdentifier ( ) , true ) -> setIssuedAt ( time ( ) ) -> setNotBefore ( time ( ) ) -> setExpiration ( $ this -> getExpiryDateTime ( ) -> getTimestamp ( ) ) -> setSubject ( $ this -> getUserIdentifier ( ) ) -> set ( 'scopes' , $ this -> getScopes ( ) ) ; // add user name to claims if ( $ this -> getUserIdentifier ( ) ) { $ userEntity = $ this -> getUserEntity ( ) ; $ member = $ userEntity -> getMember ( ) ; $ tokenBuilder -> set ( 'fn' , $ member ? $ member -> FirstName : null ) -> set ( 'ln' , $ member ? $ member -> Surname : null ) ; } return $ tokenBuilder -> sign ( new Sha256 ( ) , new Key ( $ privateKey -> getKeyPath ( ) , $ privateKey -> getPassPhrase ( ) ) ) -> getToken ( ) ; }
Generate a JWT from the access token

@param CryptKey $privateKey

@return string
Generate a JWT from the access token