

def test_token_endpoint_unauth(self):
    authreq = AuthorizationRequest(state='state', redirect_uri='http://example.com/authz', client_id='client1', response_type='code')
    _sdb = self.provider.sdb
    sid = _sdb.access_token.key(user='sub', areq=authreq)
    access_grant = _sdb.token_factory['code'](sid=sid)
    _sdb[sid] = {
        'oauth_state': 'authz',
        'sub': 'sub',
        'authzreq': authreq.to_json(),
        'client_id': 'client1',
        'code': access_grant,
        'code_used': False,
        'redirect_uri': 'http://example.com/authz',
        'response_type': ['code'],
    }
    areq = AccessTokenRequest(code=access_grant, redirect_uri='http://example.com/authz', client_id='client2', client_secret='hemlighet', grant_type='authorization_code')
    resp = self.provider.token_endpoint(request=areq.to_urlencoded())
    atr = TokenErrorResponse().deserialize(resp.message, 'json')
    assert _eq(atr.keys(), ['error_description', 'error'])

dataset/ETHPy150Open rohe/pyoidc/tests/test_ext_provider.py TestProvider.test_token_endpoint_unauth/original