def __call__(self, sid, *args, **kwargs):
        """
        Return a token.

        :return:
        """
        try:
            _sinfo = kwargs['sinfo']
        except KeyError:
            exp = self.do_exp(**kwargs)
            _tid = kwargs['target_id']
        else:
            if 'lifetime' in kwargs:
                _sinfo['lifetime'] = kwargs['lifetime']
            exp = self.do_exp(**_sinfo)
            _tid = _sinfo['client_id']
            if 'scope' not in kwargs:
                _scope = None
                try:
                    _scope = _sinfo['scope']
                except KeyError:
                    ar = json.loads(_sinfo['authzreq'])
                    try:
                        _scope = ar['scope']
                    except KeyError:
                        pass
                if _scope:
                    kwargs['scope'] = ' ' .join(_scope)

            if self.usage == 'authorization_grant':
                try:
                    kwargs['sub'] = _sinfo['sub']
                except __HOLE__:
                    pass

            del kwargs['sinfo']

        if 'aud' in kwargs:
            if _tid not in kwargs['aud']:
                kwargs['aud'].append(_tid)
        else:
            kwargs['aud'] = [_tid]

        if self.usage == 'client_authentication':
            try:
                kwargs['sub'] = _tid
            except KeyError:
                pass
        else:
            if 'azp' not in kwargs:
                kwargs['azp'] = _tid

        for param in ['lifetime', 'grant_type', 'response_type', 'target_id']:
            try:
                del kwargs[param]
            except KeyError:
                pass

        try:
            kwargs['kid'] = self.extra_claims['kid']
        except:
            pass

        _jti = '{}-{}'.format(self.type, uuid.uuid4().hex)
        _jwt = self.pack(jti=_jti, exp=exp, **kwargs)
        self.db[_jti] = sid
        return _jwt
dataset/ETHPy150Open rohe/pyoidc/src/oic/extension/token.py/JWTToken.__call__