protected function createIdToken(AccessTokenEntityInterface $accessToken, ClaimsSet $claims)
    {
        $issuer = $this->site->getSite();

        // Initialize the builder
        $builder = (new Builder())
            ->setAudience($accessToken->getClient()->getIdentifier())
            ->setIssuer($issuer->getSiteCanonicalURL())
            ->setIssuedAt(time())
            ->setNotBefore(time())
            ->setExpiration($accessToken->getExpiryDateTime()->getTimestamp())
            ->setSubject($accessToken->getUserIdentifier());

        // Apply claims
        foreach ($claims->jsonSerialize() as $key => $claim) {
            $builder->set($key, $claim);
        }

        // Return the newly signed token
        return $builder
            ->sign(new Sha256(), new Key($this->privateKey->getKeyPath(), $this->privateKey->getPassPhrase()))
            ->getToken();
    }