POST http://yourserver.com/services/logout |
What does it do?
Terminates your browser session. Use this to end a session using an AJAX call.
POST requests only
This REST API only accepts POST requests, not GET requests. Also, the POST request needs to include a cross-site request forgery (csrf) token.
The csrf token is a unique code which, by including it in the request, also makes the POST request unique and therefore much more secure.
The csrf token is obtained by first logging in to Elvis Server through a POST request. The response that is received will include the csrf token which can then be used in subsequent POST requests as a http header:
"X-CSRF-TOKEN: <some_csrf_token>"
For more information including examples, see Elvis 6 REST API - Performing a POST request with a csrf token.
Parameters
This service has no parameters.
Return value
- logoutSuccess. 'true'. Indicates that logout was successful.
Note: Logging out through AJAX won't work if you are doing cross-domain calls, since session cookies are not accepted when received through a cross-domain AJAX call. Use "logout and redirect" instead, see below.
Logout and redirect
GET/POST http://yourserver.com/logout ?logoutSuccessUrl=<url> |
Redirects to a 'success' URL after terminating the session. The URL can be a relative or absolute URL and can even redirect to a different server.
When no logoutSuccessUrl is specified, the user will be redirected to the configured landing page (by default this is the client install page).
Examples
AJAX logout with success
The following shows the response of a successful logout.
logout http://demo.elvisdam.com/services/logout |
{
"logoutSuccess" : true
}
Redirect logout
Ends the session and redirects to www.elvisdam.com.
logout
http://demo.elvisdam.com/logout ?logoutSuccessUrl=http%3A%2F%2Fwww.elvisdam.com |
Comment
Do you have corrections or additional information about this article? Leave a comment! Do you have a question about what is described in this article? Please contact Support.
1 comment
With Powershell this code works:
Took me a while to figure it out. Maybe someone needs it.
$token = ""
$urlLogin = 'http://<elvisserver>/services/apilogin?
cred=<base64 credentials>
&username=<user>
&password=<password>'
$urlLogout = 'http://<elvisserver>/services/logout'
$responseLogin = Invoke-RestMethod -Method 'Post' -Uri $urlLogin
$token = $responseLogin.authToken
$headers = @{
'Content-Type' = 'application/json'
'Authorization' = ''
}
$headers.'Authorization' = 'Bearer ' + $token
$headers
$responseLogout = Invoke-RestMethod -Method 'Post' -Headers $headers -Uri $urlLogout
Write-Host $responseLogout
Please sign in to leave a comment.