Developer API

Manage Users

35 views 0

Manage Users via the Application API

The users for your ZivaCare application are mainly managed using the ZivaCare Connect flow. Your ZivaCare application users may be managed easily from your ZivaCare Developer Dashboard. Additionally, more flexibility is allowed programmatically, using the API presented below.

Create Application User

For creating a user in your ZivaCare application, you will need to specify the clientId and clientSecret parameters. You may find these in your ZivaCare application settings.
Each new user must have a unique identifier (clientUserId). This may be very well an e-mail address. Additionally, you are required to give a name for your user (clientUserName).

curl -X POST -H "Content-Type: application/json" -d '{
 "clientId": "98_qwltgajrkis0wcw804scksk00cssck8w4wo48oogkwosk8gw8",
 "clientSecret": "27gdxjvgi9z4kc00s0wo8kgo0okg0sw0so0wskgs000swo80os",
 "clientUserId": "john.doe@zivacare.com",
 "clientUserName": "John Doe"
 }' https://developer.zivacare.com/api/v2/app/create-user
HTTP RESPONSE CODE JSON RESPONSE
200 {
“specialToken”:”NTMzY2E5NWU0ZThiYTQ2OGY1NDEyYWE1MTdmMWY2OTEyMTI3MWFiOWNhODEwMDkwYTUwYjcyYTAwYmRjZTFjZg”,
“clientId”:”1_58pwgm81sg00ksogo40og8gcogckcwwoww4sw4owggsw844kgg”,
“clientUserId”:”john.doe@zivacare.com”,
“clientUserName”:”John Doe”
}
400 { “code”: “0001”, “message”: “Cannot assign user to application! Found duplicate unique user identifier (clientUserId).” }
{ “code”: “0004”, “message”: “You did not provide an application client Id! clientId parameter is missing.” }
{ “code”: “0005”, “message”: “You did not provide a client user Id! clientUserId parameter is missing.” }
{ “code”: “0007”, “message”: “You did not provide an application client secret! clientSecret parameter is missing.” }
{ “code”: “0011”, “message”: “Your application is not recognized! Check both clientId and clientSecret.” }
{ “code”: “0012”, “message”: “Your application is not recognized! Check clientId.” }
{ “code”: “0021”, “message”: “Invalid JSON!. Please check that JSON is valid.” }
{ “code”: “0023”, “message”: “You must provide the client user name! clientUserName parameter is missing.” }
{ “code”: “0024”, “message”: “Unable to create user profile. Probably there is an existing profile in API!” }

Get Access Token

Once you have your user created in your ZivaCare application, you will need to request an access token.
The access token for the user may be obtained using the specialToken returned by Create Application User. For security purposes the client secret (clientSecret) of your ZivaCare application must be specified as well.

curl -X POST -H "Content-Type: application/json" -d '{
 "clientSecret": "98_qwltgajrkis0wcw804scksk00cssck8w4wo48oogkwosk8gw8",
 "specialToken": "NTMzY2E5NWU0ZThiYTQ2OGY1NDEyYWE1MTdmMWY2OTEyMTI3MWFiOWNhODEwMDkwYTUwYjcyYTAwYmRjZTFjZg"
 }' https://developer.zivacare.com/oauth/v2/get-access-token
HTTP RESPONSE CODE JSON RESPONSE
200 {
“ziva_user_code”: “5bee5574-1e7e-4888-aaa5-6754eba2c542”,
“name”: “john doe”,
“email”: “john.doe@zivacare.com”,
“access_token”: “AszY0MjIwOTJkNmM0NjEzNDBmOTg3YmFiZjFmZmNjOWZhNjFmMzMzNDllMTBlOTlkYzJjNzE2YTYxNzRhMj”
}
400 { “code”: “0002”, “message”: “Access token generation failed. Cannot add an access token to the user! Please contact us at ZivaCare Support.” }
{ “code”: “0006”, “message”: “Your application is not recognized! Check clientSecret and specialToken.” }
{ “code”: “0007”, “message”: “You must provide the application secret (clientSecret parameter is missing)!” }
{ “code”: “0008”, “message”: “Your special toekn (specialToken) is invalid!” }
{ “code”: “0009”, “message”: “OAuth2 token service not reachable at https://developer.zivacare.com/oauth/v2/token. Please contact us at ZivaCare Support.” }
{ “code”: “0010”, “message”: “This method accepts only POST!” }
{ “code”: “0016”, “message”: “You must provide the special Token! specialToken parameter is missing. You may obtain it by calling https://developer.zivacare.com/api/v2/app/create-user.” }

Set Application User Data Source Token

For any user of your ZivaCare application, you are permitted to programmatically set the authorization token obtained for a certain data source. This is useful when you already have tokens for your users and you do not wish your users to do the ZivaCare Connect process.

Currently, the following data sources are supported: fitbit, runkeeper, humanapi. Use these values for the dataSourceName parameter, when referring to Fitbit, RunKeeper and respectively Human API.

You user’s token must be placed in the token parameter. There is one exception though. Fitbit offers a consumer key and a consumer secret. Both values are required for a Fitbit data source. Please make sure you place the consumer key in the tokenparameter and the consumer secret in the secret parameter. Otherwise, the secret parameter is optional and may be omitted.

Below are two usage examples. One is for a RunKeeper data source and the other is for Fitbit. Note that, for Fitbit, although the secret parameter is optional you need to specify it. Failing to do so will prevent ZivaCare from accessing the user’s Fitbit data.

clientId and clientSecret refer to your ZivaCare application client ID and client secret.

Please note that if your application user already has a token set for a given data source, that token and secret will be overwritten!

curl -X POST -H "Content-Type: application/json" -d '{
 "clientId": "98_qwltgajrkis0wcw804scksk00cssck8w4wo48oogkwosk8gw8",
 "clientSecret": "27gdxjvgi9z4kc00s0wo8kgo0okg0sw0so0wskgs000swo80os",
 "clientUserId": "john.doe@zivacare.com",
 "dataSourceName": "runkeeper",
 "token": "AszY0MjIwOTJkNmM0NjEzNDBmOTg3YmFiZjFmZmNjOWZhNjFmMzMzNDllMTBlOTlkYzJjNzE2YTYxNzRhMj"
}' https://developer.zivacare.com/api/v2/app/set-application-user-data-source-token
curl -X POST -H "Content-Type: application/json" -d '{
 "clientId": "98_qwltgajrkis0wcw804scksk00cssck8w4wo48oogkwosk8gw8",
 "clientSecret": "27gdxjvgi9z4kc00s0wo8kgo0okg0sw0so0wskgs000swo80os",
 "clientUserId": "john.doe@zivacare.com",
 "dataSourceName": "fitbit",
 "token": "AszY0MjIwOTJkNmM0NjEzNDBmOTg3YmFiZjFmZmNjOWZhNjFmMzMzNDllMTBlOTlkYzJjNzE2YTYxNzRhMj",
 "secret": "df4dsasgh7dkkjamsndfddhui"
}' https://developer.zivacare.com/api/v2/app/set-application-user-data-source-token
HTTP RESPONSE CODE JSON RESPONSE
204
400 { “code”: “0004”, “message”: “You did not provide an application client Id! clientId parameter is missing.” }
{ “code”: “0006”, “message”: “Your application is not recognized! Check clientSecret and specialToken.” }
{ “code”: “0007”, “message”: “You must provide the application secret (clientSecret parameter is missing)!” }
{ “code”: “0011”, “message”: “Your application is not recognized! Check both clientId and clientSecret.” }
{ “code”: “0012”, “message”: “Your application is not recognized! Check clientId.” }
{ “code”: “0017”, “message”: “Your data source is not recognized! Check that dataSourceName has a valid value.” }
{ “code”: “0018”, “message”: “You did not provide a data source! dataSourceName parameter is missing.” }
{ “code”: “0019”, “message”: “You did not provide a token! token parameter is missing.” }
{ “code”: “0021”, “message”: “Invalid JSON!. Please check that JSON is valid.” }

Delete a User

You can see an example below how to delete a user that belongs to an application.

curl -X DELETE https://developer.zivacare.com/api/v2/app/{clientId}/users/{zivaUserCode}
HTTP RESPONSE CODE JSON RESPONSE
204
400 { “code”: “0012”, “message”: “Your application is not recognized! Check clientId.” }
{ “code”: “0025”, “message”: “Your ziva user code is invalid or missing!” }

Was this helpful?

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close