def pack(self, kid='', owner='', **kwargs):
        keys = self.keyjar.get_signing_key(jws.alg2keytype(self.sign_alg),
                                           owner=owner, kid=kid)

        if not keys:
            raise NoSuitableSigningKeys('kid={}'.format(kid))

        key = keys[0]  # Might be more then one if kid == ''

        if key.kid:
            kwargs['kid'] = key.kid

        iat = utc_time_sans_frac()
        if not 'exp' in kwargs:
            kwargs['exp'] = iat + self.lifetime

        try:
            _encrypt = kwargs['encrypt']
        except __HOLE__:
            _encrypt = self.encrypt
        else:
            del kwargs['encrypt']

        _jwt = self.message_type(iss=self.iss, iat=iat, **kwargs)

        if 'jti' in self.message_type.c_param:
            try:
                _jti = kwargs['jti']
            except:
                _jti = uuid.uuid4().hex

            _jwt['jti'] = _jti

        _jws = _jwt.to_jwt([key], self.sign_alg)
        if _encrypt:
            return self._encrypt(_jws)
        else:
            return _jws
dataset/ETHPy150Open rohe/pyoidc/src/oic/utils/jwt.py/JWT.pack