# Grant type 'client\_crendetials' not allowed for the client

**URL:** <https://community.auth0.com/t/grant-type-client-crendetials-not-allowed-for-the-client/136648>\
**Category:** Get Help\
**Tags:** client-grants, management-api\
**Created:** [June 19, 2024, 1:27pm UTC](https://community.auth0.com/t/grant-type-client-crendetials-not-allowed-for-the-client/136648 "2024-06-19T13:27:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthur.bastos](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@arthur.bastos](https://community.auth0.com/u/arthur.bastos)\
**Post date:** [June 19, 2024, 1:27pm UTC](https://community.auth0.com/t/grant-type-client-crendetials-not-allowed-for-the-client/136648/1 "2024-06-19T13:27:41Z")

</div>

I’m trying to implement AuthO on my Kafka Python application but i get this error:

Response status: 403  
Response text: {“error”:“unauthorized\_client”,“error\_description”:“Grant type ‘client\_crendetials’ not allowed for the client.”,“error\_uri”:“[Application Grant Types](https://auth0.com/docs/clients/client-grant-types)”}  
Traceback (most recent call last):  
File “/data/work/kafka-docker/python/main.py”, line 12, in   
token = auth0.get\_token()  
^^^^^^^^^^^^^^^^^  
File “/data/work/kafka-docker/python/auth0.py”, line 31, in get\_token  
response.raise\_for\_status()  
File “/usr/lib/python3/dist-packages/requests/models.py”, line 1021, in raise\_for\_status  
raise HTTPError(http\_error\_msg, response=self)  
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: [https://dev-2wlje8cth5bo7kri.us.auth0.com/oauth/token](https://dev-2wlje8cth5bo7kri.us.auth0.com/oauth/token)

I tested getting the token in a test class before, using the same application an API, and it worked.

I also checked the settings and everything seems to be configured correctly.

Here is my Python code:

main.py

> from auth0 import Auth0
> 
> from kafka\_client import KafkaClient
> 
> AUTH0\_DOMAIN = ‘[dev-2wlje8cth5bo7kri.us.auth0.com](http://dev-2wlje8cth5bo7kri.us.auth0.com)’
> 
> CLIENT\_ID = ‘CLIENT\_ID’
> 
> CLIENT\_SECRET = ‘CLIENT\_SECRET’
> 
> AUDIENCE = ‘[https://myapi/](https://myapi/)’
> 
> BOOTSTRAP\_SERVERS = ‘localhost:9092’
> 
> GROUP\_ID = ‘my-group’
> 
> auth0 = Auth0(AUTH0\_DOMAIN, CLIENT\_ID, CLIENT\_SECRET, AUDIENCE)
> 
> token = auth0.get\_token()
> 
> print(f"Token: {token}")
> 
> kafka\_client = KafkaClient(BOOTSTRAP\_SERVERS,token)
> 
> producer = kafka\_client.create\_producer()
> 
> consumer = kafka\_client.create\_consumer(GROUP\_ID)

auth0.py

> import requests
> 
> import json
> 
> class Auth0:
> 
> def **init** (self, domain, client\_id, client\_secret, audience):
> 
> self.domain =domain
> 
> self.client\_id = client\_id
> 
> self.client\_secret = client\_secret
> 
> self.audience = audience
> 
> def get\_token(self):
> 
> url =f"https://{self.domain}/oauth/token"
> 
> headers = {
> 
> ‘content-type’: ‘application/json’
> 
> }
> 
> data = {
> 
> ‘client\_id’ : self.client\_id,
> 
> ‘client\_secret’: self.client\_secret,
> 
> ‘audience’ : self.audience,
> 
> ‘grant\_type’ : ‘client\_crendetials’
> 
> }
> 
> response = requests.post(url, headers=headers, data=json.dumps(data))
> 
> print(f"Response status: {response.status\_code}")
> 
> print(f"Response text: {response.text}")
> 
> response.raise\_for\_status()
> 
> token = response.json()[‘acess\_token’]
> 
> return token

kafka\_client.py

> from confluent\_kafka import Producer, Consumer, KafkaError
> 
> class KafkaClient:
> 
> def **init** (self, bootstrap\_servers, token):
> 
> self.bootstrap\_servers = bootstrap\_servers
> 
> self.token = token
> 
> def create\_producer(self):
> 
> conf = {
> 
> ‘bootstrap.servers’: self.bootstrap\_servers,
> 
> ‘security.protocol’: ‘SASL\_SSL’,
> 
> ‘sasl.mechanisms’: ‘OAUTHBEARER’,
> 
> ‘sasl.oauthbearer.config’: f"token={self.token}"
> 
> }
> 
> producer = Producer(\*\*conf)
> 
> return producer
> 
> def create\_consumer(self, group\_id):
> 
> conf = {
> 
> ‘bootstrap.servers’: self.bootstrap\_servers,
> 
> ‘security.protocol’:‘SASL\_SSL’,
> 
> ‘sasl\_mechanisms’: ‘OAUTHBEARER’,
> 
> ‘sasl.oauthbearer.config’: f"token={self.token}",
> 
> “group.id”:group\_id,
> 
> ‘auto.offset.reset’:‘earliest’
> 
> }
> 
> consumer = Consumer(\*\*conf)
> 
> return consumer

And here is the test class that get the token without the error:

get\_token.py

> import requests
> 
> import json
> 
> def get\_auth0\_token():
> 
> AUTH0\_DOMAIN = ‘[dev-2wlje8cth5bo7kri.us.auth0.com](http://dev-2wlje8cth5bo7kri.us.auth0.com)’
> 
> CLIENT\_ID = ‘CLIENT\_ID’
> 
> CLIENT\_SECRET = ‘CLIENT\_SECRET’
> 
> AUDIENCE = ‘[https://myapi/](https://myapi/)’
> 
> url = f"https://{AUTH0\_DOMAIN}/oauth/token"
> 
> headers = {
> 
> ‘content-type’: ‘application/json’
> 
> }
> 
> data = {
> 
> ‘client\_id’: CLIENT\_ID,
> 
> ‘client\_secret’: CLIENT\_SECRET,
> 
> ‘audience’: AUDIENCE,
> 
> ‘grant\_type’: ‘client\_credentials’
> 
> }
> 
> response = requests.post(url, headers=headers, data=json.dumps(data))
> 
> response.raise\_for\_status()
> 
> token = response.json()[‘access\_token’]
> 
> return token
> 
> token = get\_auth0\_token()
> 
> print(f"Token: {token}")

And here is my settings, to check if i missed anything:

Client:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/0/4/04047190abc393bcf572d60c8594b87b5cafc24c.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/2/2/2201fc52e56daa77931cb1ace48bdc27697e38f7.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/0/70e9f186b20a0a280cbf44b10f5240f9d5670a86.png)

API:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/6/f/6fd99deb635161c8b32b24952c5ce5c6ebeaa7a8.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/4/f/4fa1b832b58daf6219ff9c974dad36c910cb4493.png)

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [May 28, 2025, 3:51pm UTC](https://community.auth0.com/t/grant-type-client-crendetials-not-allowed-for-the-client/136648/4 "2025-05-28T15:51:18Z")

</div>

Hi there,

Thank you for reaching out to us!

We are trying to reply and provide some information to older posts, in case others encounter the same situation and it could help them too.

Looking at the settings, I believe everything should be correct. My suspicion is that the current M2M application that you are using was previously set up as a different type, a Native or Spa app for example. Changing the Application type can sometimes cause these issues, despite setting everything correctly. Please see more information on our documentation on this error message : [Calling /oauth/token Returns Grant Type 'client\_credentials' Not Allowed for the Client](https://community.auth0.com/t/calling-oauth-token-returns-grant-type-client-credentials-not-allowed-for-the-client/164559)

I would advise to create a new [M2M application](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) altogether and check with that is you are getting the same error. This should clear out any conflicts that happen to still be ongoing, but not detectable.

Hope that helped!  
Gerald

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 11, 2025, 3:51pm UTC](https://community.auth0.com/t/grant-type-client-crendetials-not-allowed-for-the-client/136648/5 "2025-06-11T15:51:25Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
