Create a user in Open Edx from third party website

Hi :slight_smile:

Can i create/register a user in Open Edx from an external domain? Is this possible? I mean, create it in one click, retrieving data from a form.

I have tested the creation using mysql externally already and it works, but i want something more elegant.

I have seen a post in StackOverflow that recommend using user_api/v1/account/registration/ url and a POST method, can anyone confirm this? Link to the post related

Thanks a lot :slight_smile:

1 Like

Hi,

Try the following

Create the applications at: https://lms_domain_name/admin/oauth2_provider/application/

  • Client 1:

    • Client ID: [generated client id]

    • Client Type: Confidential

    • Authorization grant type: Authorization Code

    • Client Secret: [generated client secret]

  • Client 2:

    • Client ID: [generate client id]

    • Client Type: Confidential

    • Authorization grant type: Client Credentials

    • Client Secret: [generated client secret]

API Endpoints:

Access Token:

  • https://lms_domain_name/oauth2/access_token

  • grant_type=client_credentials

  • client_id=

  • client_secret=

  • token_type=jwt

User Registration:

  • https://lms_domain_name/user_api/v1/account/registration/

  • Authorization: Bearer (access token retrieved)

  • parameters:

    • name

    • username

    • password

    • terms_of_service=true

    • honor_code=true

    • country=LB

    • email

Login

  • https://lms_domain_name/user_api/v1/account/login_session/

  • Authorization: Bearer (access token retrieved)

  • parameters:

    • password

    • email

3 Likes

Also don’t forget to change configuration as follows:

In edx/app/edxapp/lms.env.json file:

“FEATURES” : {


“ENABLE_OAUTH2_PROVIDER”: true,
“ENABLE_COMBINED_LOGIN_REGISTRATION”: true
}

2 Likes

hi @johnnyak

I created my own login system using your instruction, yes it works and push the data

  • name
  • username
  • password
  • terms_of_service=true
  • honor_code=true
  • country=PH
  • email

from user admin studio

but I want is after registering it should be auto redirect to learner-dashboard

do you have any suggestion about that ?

the error I encountered

Access to XMLHttpRequest at ‘https://domain/learner-dashboard/’ (redirected from ‘https://localhost:44391/Home/Register’) from origin ‘https://localhost:44391’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.Understand this error
angular.js:14642 Possibly unhandled rejection: {“data”:null,“status”:-1,“config”:{“method”:“POST”,“transformRequest”:[null],“transformResponse”:[null],“jsonpCallbackParam”:“callback”,“url”:“https://localhost:44391/Home/Register",“data”:{“username”:“juandelacruz”,“email”:“juandelacruz@gmail.com”,“password”:“qwerty”,“name”:"Juan Dela Cruz”,“language”:“”,“location”:“”},“headers”:{“Content-Type”:“application/json”,“Access-Control-Allow-Methods”:“*”,“Access-Control-Allow-Credentials”:true,“Accept”:“application/json, text/plain, /”}},“statusText”:“”}
(anonymous) @ angular.js:14642
(anonymous) @ angular.js:11102
processChecks @ angular.js:17028
$digest @ angular.js:18182
$apply @ angular.js:18480
done @ angular.js:12501
completeRequest @ angular.js:12727
requestError @ angular.js:12665
error (async)
(anonymous) @ angular.js:12668
sendReq @ angular.js:12446
serverRequest @ angular.js:12198
processQueue @ angular.js:17000
(anonymous) @ angular.js:17044
$digest @ angular.js:18182
$apply @ angular.js:18480
(anonymous) @ angular.js:27290
dispatch @ jquery-3.4.1.js:5237
elemData.handle @ jquery-3.4.1.js:5044Understand this error
angular.js:12701

   GET https://domain/learner-dashboard/ net::ERR_FAILED