5. User¶
5.1. Create user¶
- User can create an account on W2E main site or
- Application can create account for the user:
method | HTTP POST |
uri | https://w2e.fi/api/organization/users |
json parameter | description |
---|---|
client_id | Client ID you are given in registration |
client_secret | Client secret you are given in registration |
Curl example:
curl -X POST https://w2e.fi/api/organization/users -H "Content-Type: application/json" -d '{"client_id":"XHaeSTbLr1dusWvH","client_secret":"3qCtNaUIH0x11HGjY1Kp9HrdOprT5uRFOeSMFbmqC9WQ6kWcZAzQ44lA0IyIWF6q"}'
Response example:
{"access_token": "XHaeSTbLr1dusWvHlnZOXr6LR0jNmReuQtCbw0WsMj44Ktfs", "username": "qapjzpzxyqtrkusi", "expires": "2015-08-07T12:09:42Z", "refresh_token": "EXX9oaboKOWeUibouz228FmlsIzVdUSwW3X6Y260zbW858cBQCbZNFA4349LoZcc"}
5.2. Get application’s users¶
- Get information of all application’s users
method | HTTP GET |
uri | https://w2e.fi/api/organizations/{client_id}/users[?user={username}] |
header | “Authorization: Bearer {client_secret}” |
username | User identifier |
Curl example:
curl -X GET -H "Authorization: Bearer 3qCtNaUIH0x11HGjY1Kp9HrdOprT5uRFOeSMFbmqC9WQ6kWcZAzQ44lA0IyIWF6q" http://localhost//api/organizations/XHaeSTbLr1dusWvH/users
Response example:
[{"access_token": "XHaeSTbLr1dusWvHlnZOXr6LR0jNmReuQtCbw0WsMj44Ktfs", "username": "qapjzpzxyqtrkusi", "expires": "2015-08-07T12:09:42Z", "refresh_token": "EXX9oaboKOWeUibouz228FmlsIzVdUSwW3X6Y260zbW858cBQCbZNFA4349LoZcc"},{"access_token": "xxx", "username": "qwerty", "expires": "2017-08-07T12:09:42Z", "refresh_token": "yyy"}]
5.3. Get user information¶
method | HTTP GET |
uri | https://w2e.fi/api/users/{username} |
header | “Authorization: Bearer {access_token}” |
username | User identifier |
access_token | Token used to access user account |
Curl example:
curl -X GET https://w2e.fi/api/users/qapjzpzxyqtrkusi --header "Authorization: Bearer XHaeSTbLr1dusWvHlnZOXr6LR0jNmReuQtCbw0WsMj44Ktfs"
Response example:
{"sources": {"polar": {"synced": null, "linked": false}, "withings": {"synced": null, "linked": false}, "beddit": {"synced": null, "linked": false}, "fitbit": {"synced": null, "linked": false}, "moves": {"synced": null, "linked": false}, "runkeeper": {"synced": null, "linked": false}, "jawbone": {"synced": null, "linked": false}}, "applications": [], "sinks": {"taltioni": {"synced": null, "linked": false}}, "user_info": {"username": "qapjzpzxyqtrkusi", "city": null, "weight": null, "language": null, "gender": null, "birthDate": null, "height": null, "postcode": null, "country": null, "timezone": "Europe/Helsinki", "newsletter": true}}
5.4. Modify data sources¶
Application can redirect user to w2e site for linking/unlinking data sources.
- Application requests link_url from w2e
- Application redirects user to the url
- User can modify data sources in w2e
method | HTTP GET |
uri | https://w2e.fi/api/organization/users/{username}/link_token |
header | “Authorization: Bearer {access_token}” |
username | User identifier |
access_token | Token used to access user account |
Curl example:
curl -X GET https://w2e.fi/api/organization/users/qapjzpzxyqtrkusi/link_token --header "Authorization: Bearer XHaeSTbLr1dusWvHlnZOXr6LR0jNmReuQtCbw0WsMj44Ktfs"
Response example:
{"username": "qapjzpzxyqtrkusi", "token": "GNxOs0dnnpivI5BX0nh81gYd6GSFvlxg", "expires": "2014-10-07T12:41:15Z", "link_url": "https://w2e.fi/link#/?link_token=GNxOs0dnnpivI5BX0nh81gYd6GSFvlxg"}