Authentication credentials were not provided

I am getting bellow error when i calling this api api/user/v1/users

Authentication credentials were not provided.

As i tried both the method of token_type: JWT and Bearer same
I am taking token from this api oauth2/access_token

  • version: maple
  • I created client id and secret. I am using client id and secret to generate access_token

@chethan4046 here are the steps to call API which supports Bearer authentication via oauth2

  1. Create django oauth privider application with client credentials selected as Grant Type. Save Client id and Client Secret of your application

  2. Get access_token by send a post request to {lms_url}/oauth2/access_token endpoint with grant_type, client_id and client_secret

curl --location --request POST '{lms_url}/oauth2/access_token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_secret=client_secret_value' \
--data-urlencode 'client_id=client_id_value'
  1. Call desired API with access_token
curl --location --request POST '{lms_url}/api/enrollment/v1/enrollment' \
--header 'Authorization: Bearer {access_token_taken_from_step2}' \
--header 'Content-Type: application/json' \
--data-raw '{
"user": "new_learner",
"course_details": {"course_id": "course-v1:edx+DEMO_100+2022_Q1"}
}'```
2 Likes

@Zia_Fazal Thanks you for your replay,
I have facing Authentication credentials were not provided. issue for limited API not for all
It working for some ex: ```
enrollment/v1/enrollment

Basically i want to get list of users; `user/v1/users`

@chethan4046 That users list API requires API KEY header. To access that API you need to set EDX_API_KEY setting for your environment and then access users list API like this

curl 'http://localhost:18000/api/user/v1/users/' -H 'X-EDX-API-KEY: PUT_YOUR_API_KEY_HERE'

in other words you have to pass a custom header in your request having your EDX_API_KEY

HTTP_X_EDX_API_KEY: PUT_YOUR_API_KEY_HERE

Thank you
Can i have some documentation or some example where to setup and how to setup EDX_API_KEY

I tried : curl ‘https://[myedx url]/api/user/v1/me’ -H ‘X-EDX-API-KEY: my-key’
The system return “Authentication credentials were not provided”.

( I want to know the username)

Could you please give me advise?

@guangyaw, that endpoint does not use EDX_API_KEY. It supports JWT and Bearer auth, as seen here:

You can try following Zia’s suggestion above.


I tried before. And I always get the username : guangyaw.
But I would like to know the username who logged in from the root of the MKTG_URL_LINK_MAP.
( How do I know the username from the root of the MKTG_URL_LINK_MAP? )