Authentication credentials were not provided

@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"}
}'```
3 Likes