Difference between revisions of "Sensaphone.net API/login"
(→Sensaphone.net API) |
|||
| Line 41: | Line 41: | ||
====Example JSON==== | ====Example JSON==== | ||
| + | Log in with a username and password using JSON mode. | ||
| + | *'''Request JSON:''' | ||
| + | { | ||
| + | "request_type:"create", | ||
| + | "resource": "login", | ||
| + | "user_name": "myusername", | ||
| + | "password": "pass123" | ||
| + | } | ||
| + | |||
| + | *'''Response JSON:''' | ||
| + | { | ||
| + | "result": { | ||
| + | "success": true, | ||
| + | "code": 0, | ||
| + | "message": "Success" | ||
| + | }, | ||
| + | "response": { | ||
| + | "acctid": 987654, | ||
| + | "session": "0123-4567-8901", | ||
| + | "login_timestamp": 1499459402, | ||
| + | "session_expiration": 86400, | ||
| + | "user_id": 00000001 | ||
| + | } | ||
| + | } | ||
| + | |||
Receive Login information for a given session UUID. | Receive Login information for a given session UUID. | ||
Revision as of 16:40, 7 July 2017
Contents
Sensaphone.net API
The Login API will be used to log in to the Sensaphone.net system. When a user logs in with their username and password they will be assigned a session UUID. The session UUID will have a corresponding time stamp and a timed expiration for their session. The session UUID and statically assigned Account ID will be used as the primary identifier instead of including a username and password in subsequent URI requests.
Example Call
https://sensaphone.net/api/v1/login/{USERNAME}/{PASSWORD}
Values
- Username
- Password
- Session UUID
- Session Time stamp
- Session Expiration
Example Requests
GET
URI Mode Request URI's:
- Receive Login information
GET https://rest.sensaphone.net/api/v1/{ACCTID}/{SESSION}/login
- Receive a Login timestamp for a session
GET https://rest.sensaphone.net/api/v1/{ACCTID}/{SESSION}/login/login_timestamp
- Receive the number of seconds until a session expires
GET https://rest.sensaphone.net/api/v1/{ACCTID}/{SESSION}/login/session_expiration
JSON MODE Request URI:
- Receive Login information
POST https://rest.sensaphone.net/api/v1/login
| Request Property | Status | Type | Description |
| acctid | Required | Integer | Static ID of user |
| session | Required | Integer | Session ID of user |
| Response Property | Included | Type | Description |
| login_timestamp | Optional | String | Time stamp of last log in |
| session_expiration | Optional | Integer | Seconds until log in expiration |
| user_id | Optional | Integer | ID of the logged in user |
Example JSON
Log in with a username and password using JSON mode.
- Request JSON:
{
"request_type:"create",
"resource": "login",
"user_name": "myusername",
"password": "pass123"
}
- Response JSON:
{
"result": {
"success": true,
"code": 0,
"message": "Success"
},
"response": {
"acctid": 987654,
"session": "0123-4567-8901",
"login_timestamp": 1499459402,
"session_expiration": 86400,
"user_id": 00000001
}
}
Receive Login information for a given session UUID.
- Request JSON:
{
"request_type:"read",
"resource":"login",
"acctid":987654,
"session":"0123-4567-8901",
"login":null
}
- Response JSON:
{
"result":
{
"success: true,
"code": 0,
"message":"OK",
},
"response":
{
"login_timestamp":"2014-12-31 23:59:59",
"session_expiration":60
}
}
PUT
PUT will be used only to update a Login session.
URI Mode Request URI:
- Request to update a Login session
PUT https://rest.sensaphone.net/api/v1/{ACCTID}/{SESSION}/login
JSON Mode Request URI:
POST https://rest.sensaphone.net/api/v1/login
| Request Property | Status | Type | Description |
| acctid | Required | Integer | Static ID of user |
| session | Required | Integer | Session ID of user |
| user_name | Optional | String | Username |
| password | Optional | String | Password for username |
| Response Property | Included | Type | Description |
| acctid | Conditionally* | Integer | Static ID of user |
| session | Conditionally* | Integer | Session ID of user |
| login_timestamp | Always | Integer | Time stamp of renewed session |
| session_expiration | Always | Integer | Time until new log in session expiration |
| user_id | Always | Integer | ID of the logged in user |
* There may be an instance where the system needs to create a new Session ID and/or Account ID. In which case, it will be outputted in the PUT response.
POST
URI Mode Request URI:
- Request for creating a new login session
POST https://rest.sensaphone.net/api/v1/login/{USERNAME}/{PASSWORD}
JSON Mode Request URI:
POST https://rest.sensaphone.net/api/v1/login
| Request Property | Status | Type | Description |
| user_name | Required | String | Username |
| password | Required | String | Password for username |
| Response Property | Type | Description |
| acctid | Integer | Static ID of user |
| session | Integer | Session ID of user |
| login_timestamp | Integer | Time stamp of renewed session |
| session_expiration | Integer | Time until new log in expiration |
| user_id | Integer | ID of the logged in user |
DELETE
Deleting a login session is the equivalent to logging out.
URI Mode Request URI:
- Request to log out of a session
DELETE https://rest.sensaphone.net/api/v1/login/{ACCTID}/{SESSION}
JSON Mode Request URI:
POST https://rest.sensaphone.net/api/v1/login
| Request Property | Status | Type | Description |
| acctid | Required | Integer | Static ID of user |
| session | Required | Integer | Session ID of user |
Future
In the future the login process will support OAuth for advanced access and authentication.
Password Reset
To reset a pass for a particular email, use the following request:
POST https://rest.sensaphone.net/api/v1/login/reset_password/{email_address}