User Cloud Storage API \ Update an existing user PHP SDK
Resource/URI | GET | POST | PUT | DELETE |
---|---|---|---|---|
Create a new user. /storage/users.json
|
– |
Create User |
– | – |
Update an existing user. /storage/users/<user_token>.json
|
– | – |
Update User |
– |
Synchronize a new or existing user. /storage/users/user/synchronize.json
|
– | – |
Synchronize User |
– |
Authenticate an existing user. /storage/users/user/lookup.json
|
– |
Authenticate User |
– | – |
Workflow
Request: the code to send to the API
Send an API request to the following endpoint in order to update a user in your OneAll cloud-storage database:
The user's cloud-storage data is kept in a distinct identity. Each user has at least one but may have multiple identities whereby each identity is corresponding to data originating from a different source.
A user record might per example have an identity with data retrieved when the user logged in with Twitter, another one with data retrieved when the user linked his Facebook account and a third one with the custom data that you have saved in the cloud storage.
The cloud storage identity itself is unique per user. If the user that you are updating has no such identity yet, then it will be added. It the user already has such an identity, then it will be updated.
POST
data to include in your request
{ "request": { "update_mode": "#update_mode#", "user": { "externalid": "#externalid#", "login": "#login#", "password": "#password#", "identity" : { "name":{ "givenName": "#givenName#", "familyName": "#givenName#" }, "gender": "#gender#" } } } }
Key | Description |
---|---|
#update_mode#string, predefined
|
Use this property to select how the properties should be updated.replace (default)
append
|
#externalid#string
|
Your own user identifier. It must be unique amongst all stored users. Only specify this property if you want to update it. Example: extid1 |
#login#string
|
The user's login. It must to be unique amongst all stored users. Only specify this property if you want to update it. Example: john.doe |
#password#string
|
The user's password. We apply a one-way hashing algorithm to all stored passwords. Only specify this property if you want to update it. Example: 12345678 |
identity \ *json
|
All additional user information is stored in a storage identity attached to the user node. Please refer to the following page for a complete list of possible values for the identity node. |
Result: the code returned by the API
The API returns either HTTP status code 202
(identity updated) or 201
(identity created), indicating a successful
request, or another status code, indicating an error in the request.
Example Resultset
{ "response": { "request": { "date": "Thu, 29 Oct 2015 16:11:58 0100", "resource": "/storage/users/2eaf5d01-8244-44b9-878d-9e83073c45e0.json", "status": { "flag": "success", "code": 200, "info": "Your request has been processed successfully" } }, "result": { "data": { "user": { "user_token": "2eaf5d01-8244-44b9-878d-9e83073c45e0", "externalid": 1, "login": "john@.doe@example.com", "date_creation": "Thu, 29 Oct 2015 16:11:57 0100", "date_last_update": "Thu, 29 Oct 2015 16:11:57 0100", "num_logins": 0, "identity": { "identity_token": "99859d8c-6422-4c47-8b5b-40928e36dbea", "date_creation": "Thu, 29 Oct 2015 16:11:57 0100", "date_last_update": "Thu, 29 Oct 2015 16:11:57 0100", "provider": "storage", "source":{ "name": "Cloud Storage", "key": "storage" }, "id": "/external/1", "gender": "male" } } } } } }
Account Mapping
This endpoint can also be used to store your own user identifiers for users that have logged in with a social network. This will allow you to recognize the users on subsequent logins with the same social network.
After a user has logged in with our Social Login service you first use the received social network profile data to create a new user record in
your database. Then you make a call to this endpoint to set the externalid
to the user id from your own database.
POST
data example
{ "request":{ "user":{ "externalid": "123456" } } }
On subsequent logins with the same social network profile the externalid
will be included in the resultset allowing you to recognize
the user.