-
Notifications
You must be signed in to change notification settings - Fork 0
Session Control
Wesley Akio edited this page Jul 11, 2017
·
5 revisions
// Session
{
token : 'f47ac10b-58cc-4372-a567-0e02b2c3d479', // Your session Token
refresh : '6ba7b810-9dad-11d1-80b4-00c04fd430c8', // Your refresh Token
expires : 600 // The validity of your session. In seconds. Counting from now. Go go go!
};// Credential
{
username : 'yourUser', // Your username
password : 'yourPass' // I'll let you guess this one...
};Before doing anything with the APIs you must login, here is how to do so:
POST /api/1.0/core/session
{
username : 'myuser',
password : 'mypass'
}201 Created // Congrats, you logged in! Here is your session, keep it safe an treat it kindly.
{
token : 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
refresh : '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
expires : 600
}401 Unauthorized // Wrong username/password?Every once in a while your session will expire, that keeps your data safe so we can sleep at night.
If you start getting 401 Unauthorizeds it means your session expired. Since you know exactly when that's gonna happen you could be smart and prevent it!
// Remember a few lines ago when you were logging in? That stuff you received is good for something after all...
POST /api/1.0/core/session
{
token : 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
refresh : '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
expires : 600
}201 Created // Here is your fresh session, the old one was invalidated so...
{
token : 'da5674c5-58cc-4372-a567-0e02b2c3d479',
refresh : 'a0f8c52d-9dad-11d1-80b4-00c04fd430c8',
expires : 600
}401 Unauthorized // Maybe the session you're trying to refresh is too long gone or wasn't valid to begin withWhen you no longer need a session the safest thing to do is to destroy it. This is the equivalent of a Log log out and is a very nice thing to do in order to keep your data safe.
DELETE /api/1.0/core/session/{token}
204 No content // Your session is gone. Bye bye