How To Dev - Example of Registering a New User via Mobile App

×

Warning message

You can't delete this newsletter because it has not been sent to all its subscribers.

 

POST https://www.snap4city.org/drupal/api/user/register

ContentType: application/json

Accept: application/json

{

       "name": "John.Doe",

       "mail": "jdoe@me.com",

       "legal_accept": "true",

       "extras-1": "true",

       "extras-2": "true",

       "og_user_node": { "und": [{ "default":"722" }] }

}

// note that:

722 = Organization is “Greece-UNISYSTEMS”

319 = Organization is “DISIT

Etc.

 

Return 200 if user can be registered, an email is sent to the user to finish registration on the server (set password) the result is:

{   "uid": "8005",

    "uri": "https://www.snap4city.org/drupal/api/user/8005"

}

 

Return 406 in case of error like existing username or existing email address.

{ "form_errors": {

  "name": "The name <em class=\"placeholder\">p.bellini</em> is already taken."

    }

}

This approach can be used to register the new user from a mobile or Web App. In any case, the finalization of the registration will have to be performed (on the basis of the links received on the email address provided) on the Portal (in general case on snap4city.org, or other snap4tech platform from which the registration is requested). This two steps registration is a minimal secure practice.

It has no sense to provide the possibility of setting a password in one shot via an API only by knowing a user ID, since it would allow to any user to change the password of any other users.

Once the registration is finalized on the portal providing a preferred password, the user can enter in the mobile App with the credentials, and the mobile App can use the following functionalities to get Access Token to send data messages on broker via NGSI V1/V2, as well as to get data from smart city API.