Logout through URL not working

Hi,

I am attempting to logout from our custom app. We use Token Implicit Grant to log in.
When I logout, the link I use is the following:

https://login.mypurecloud.com/logout?client_id={your client id}&redirect_uri={a registered redirect for your app}

as recommended here https://developer.genesys.cloud/api/rest/authorization/#examples.

PROBLEM:

Not much happens when I redirect the browser to that logout URL. The page seems to reload without logging out. If I refresh the page, the user is still logged in. Then after a series of attemps, it does seem to respond correctly to the redirect requests, and it logs out but it does so after attempting various times. During all those previous attemps all it does is refresh the page. At the beggining I thought that perhaps it was a browser related issue (our app is to run on Internet Explorer 11) but I also ran the program in Chrome with similar results.

I have tried using location.replace, location.href, and various other javascript methods for the redirecting, as well as simply setting the href attribute of an anchor tag to the logout URL. Nothing works. The redirect address is registered in the OAUTH credentials section correctly, and the client ID is also correct.

What am I doing wrong?

Thank you.

What task are you actually trying to accomplish? Genesys Cloud doesn't have a concept of "logged in/out", but there are a few options to simulate such behavior depending on exactly what you're trying to do.

Generally, an app can just forget its auth token to "log out" the user. This would mean clearing the value from local storage or wherever you're storing it. When the user decides to "log in" in your app again, they will be redirected to the Genesys Cloud auth service to authenticate, which will likely automatically complete using the stored auth cookie without prompting and return a new auth token for the same user that was used previously.

If you'd like for the user to be prompted for authorization on the next login, redirect them to https://login.mypurecloud.com/logout (using the appropriate regional URL) to destroy the auth cookie. You can also initiate the OAuth flow using prompt=login to force the user to be prompted for credentials regardless of if they have a valid auth cookie or not. https://developer.genesys.cloud/api/rest/authorization/additional-parameters#force-prompt-the-user-for-credentials

If your app is remembering the auth token and reusing it when the user comes back, this is expected and is why it's recommended for the app to simply forget its token. For performance reasons, auth tokens are cached by the API service so they may continue to work for up to a couple minutes after the auth service has destroyed the token. If you must forcibly destroy the specific token, you can do so using DELETE /api/v2/tokens/me. That's not a normal pattern though. Forgetting the token that was used is typically sufficient.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.