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