def test_token_endpoint_client_credentials(self): authreq = AuthorizationRequest(state="state", redirect_uri="http://example.com/authz", client_id="client1") _sdb = self.provider.sdb sid = _sdb.access_token.key(user="******", areq=authreq) access_grant = _sdb.access_token(sid=sid) _sdb[sid] = { "oauth_state": "authz", "sub": "sub", "authzreq": "", "client_id": "client1", "code": access_grant, "code_used": False, "redirect_uri": "http://example.com/authz", 'token_endpoint_auth_method': 'client_secret_basic', } areq = CCAccessTokenRequest(grant_type='client_credentials') authn = 'Basic Y2xpZW50Mjp2ZXJ5c2VjcmV0=' resp = self.provider.token_endpoint(request=areq.to_urlencoded(), authn=authn) parsed = TokenErrorResponse().from_json(resp.message) assert parsed['error'] == "unsupported_grant_type"
def test_init(self): cc = CCAccessTokenRequest(scope="/foo") assert cc["grant_type"] == "client_credentials" assert cc["scope"] == ["/foo"]