Logging out
When the user wants to log out, the first step is to invalidate the token they are currently using. The following request returns a 204 response on success.
- PHP
- GO
- Node
- Shell
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer $accessToken"
],
CURLOPT_URL => "https://auth.openticket.tech/tokens/current"
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
req, _ := http.NewRequest("PUT", "https://auth.openticket.tech/tokens/current", bytes.NewBuffer(body))
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer " + accessToken)
resp, _ := http.DefaultClient.Do(req)
respBody, _ := io.ReadAll(resp.Body)
fmt.Println(string(respBody))
const options = {
"method": "DELETE",
"headers": {
"Accept": "application/json",
"Authorization": `Bearer ${accessToken}`
}
};
fetch("https://auth.openticket.tech/tokens/current", options)
.then(response => response.json())
.then(response => console.log(response))
curl -X DELETE \
-H "Accept: application/json" \
-H "Authorization: Bearer $accessToken" \
"https://auth.openticket.tech/tokens/current"
It is not possible to programmatically log the user out of their session as well. Since the user's session is shared by all clients, any single client cannot end the session, that is something the user must decide for themselves.
After you have invalidated the token, we recommend you redirect the user back to the Login App, on
the https://login.openticket.tech/login?client_id=...&redirect_uri=...&state=...
endpoint, using the parameters of your own OAuth client. In general, the user's session will still
be valid, but it is possible they have already ended their session.
If the user's session is still valid, the redirect will go straight to the company selection step. This makes it easy to log right back in and use your integration with another of their companies. This screen also has a logout button, with which the user can end their session.
If the user has already ended their session, the redirect will go to the login screen. If the user wants to log back into your integration, they can of course do so.