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
Zia_Fazal
(Zia Fazal)
January 27, 2022, 9:11am
2
@chethan4046 here are the steps to call API which supports Bearer authentication via oauth2
Create django oauth privider application with client credentials selected as Grant Type . Save Client id and Client Secret of your application
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'
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"}
}'```
3 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`
Zia_Fazal
(Zia Fazal)
January 27, 2022, 1:33pm
4
@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
guangyaw
(Guangyaw Li)
April 8, 2022, 3:19am
6
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?
arbrandes
(Adolfo R. Brandes)
April 8, 2022, 1:42pm
7
@guangyaw , that endpoint does not use EDX_API_KEY
. It supports JWT and Bearer auth, as seen here:
authentication_classes = (
JwtAuthentication, BearerAuthenticationAllowInactiveUser, SessionAuthenticationAllowInactiveUser
)
permission_classes = (permissions.IsAuthenticated, CanGetAccountInfo)
You can try following Ziaâs suggestion above .
guangyaw
(Guangyaw Li)
April 8, 2022, 2:45pm
8
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? )
@chethan4046 , did you get ahead with this? Where you able to set EDX_API_KEY and retrieve the user list using /api/user/v1/users API?