Getting 401 error : "invalid_client" in django-oauth-toolit

I am trying to have an Ouath2 access token based authentication. I am using django-oauth-toolkit for that. I have registered my app on http://localhost:8000/o/applications.

enter image description here

However, When I tried to hit the URL http://localhost:8000/o/token/ from the react-app . I got 401.

enter image description here

Here is my the useEffect hook that I used for calling that URL :

useEffect(() => {

fetch("http://localhost:8000/o/token/", {
    body: new URLSearchParams({
        grant_type: 'client_credentials',
        client_id: 'my_client_id',
        client_secret: 'my_client_secret'
    headers: {
        "Content-Type": "application/x-www-form-urlencoded"
    method: "POST"
}, [])

Will look forward to some comments and solutions.

I got the solution. Actually I was Using the encrypted version of the client secret. I forgot to copy it before saving. Once it is saved the value is encrypted. So it's better to copy it somewhere prior saving it.

Back to Top