Skip to main content
Bounty Ended with 200 reputation awarded by Patrick Kenny
added 777 characters in body
Source Link

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's, this module provides a user interface for administrating Rest Endpoints. Using this module's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST

Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

Another PS: If you need to require user to confirm his/her email, then you can use a simple solution, like add a verify code to user (prevent user access to this field using Field Permissions module) then in hook_user_presave you can assign a code to it, send user an email containing this code and finally deactivate user) , finally you will need a custom Rest endpoint so user can fill a form containing email field and code and if code matches the one you sent you can activate user's account.

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST

Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module, this module provides a user interface for administrating Rest Endpoints. Using this module's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST

Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

Another PS: If you need to require user to confirm his/her email, then you can use a simple solution, like add a verify code to user (prevent user access to this field using Field Permissions module) then in hook_user_presave you can assign a code to it, send user an email containing this code and finally deactivate user) , finally you will need a custom Rest endpoint so user can fill a form containing email field and code and if code matches the one you sent you can activate user's account.

added 4 characters in body
Source Link

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST EndpointPOST

Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST

Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

added 362 characters in body
Source Link

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methodsunsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST Endpoint: user/register?_format=json Header

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST Endpoint: user/register?_format=json Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

To register user using core Rest Module you need 5 steps:

Step 1: Download and enable Rest UI module and using it's configuration (admin/config/services/rest) Enable User Registration

Enable User Registration Endpoint

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked. Allow site users to create account on the site

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

allow anonymous user to register using rest

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.

Step 5: Now final step is to ask for user creation:

Method: POST Endpoint: user/register?_format=json

Header:

Content-Type: application/json
Accept: application/json
X-CSRF-Token: "XCSRF TOKEN PROVIDED BY DRUPAL"

Body:

{
  "name": [{"value": "USERNAME"}],
  "mail": [{"value": "EMAIL"}],
  "pass":[{"value": "PASSWORD"}]
}

and that's it.

PS: Remember that if you have not unchecked "require email verification" in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.

Source Link
Loading