Legacy Dev Forum Posts

 View Only

Sign Up

After logout, redirect the user to my own application

  • 1.  After logout, redirect the user to my own application

    Posted 06-05-2025 19:24

    Magudeeswaran_N | 2023-08-30 05:05:13 UTC | #1

    Hi team,

    I have been using below script to lougout the user using API,

    const platformClient = require("purecloud-platform-client-v2");
    
    const client = platformClient.ApiClient.instance;
    client.setEnvironment(platformClient.PureCloudRegionHosts.us_east_1); // Genesys Cloud region
    
    // Manually set auth token or use loginImplicitGrant(...) or loginClientCredentialsGrant(...)
    client.setAccessToken("your_access_token");
    
    let apiInstance = new platformClient.TokensApi();
    
    let userId = "userId_example"; // String | User ID
    
    // Delete all auth tokens for the specified user.
    apiInstance.deleteToken(userId)
      .then(() => {
        console.log("deleteToken returned successfully.");
      })
      .catch((err) => {
        console.log("There was a failure calling deleteToken");
        console.error(err);
      });

    but once this api executed, users automatically redirected to normal Genesys url. But I don't want that, I want thhose users to be redirected to m own application url. can you please help me out here.

    Thanks, Magu


    Magudeeswaran_N | 2023-08-30 07:37:58 UTC | #2

    Another approach I am trying is, I am redirecting the user to

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

    apiInstanceForToken.deleteToken(TokenuserId).then(e => {
    							console.log("delete response...", e);
    							var opts = {
    								method: 'post',
    								url: `https://login.mypurecloud.com/logout?client_id=${CLIENT_ID}&redirect_uri=<a registered redirect for your app>`,
    								//data: { 'useId': TokenuserId }
    							};
    							axios(opts).then(e => {
    								console.log("data", e);
    							}).catch(err => {
    								console.log("error", err);
    							})
    							console.log("Token deleted...");
    						})
    							.catch(e => console.error(e))

    It did logout the user, but still its not redirecting it to my own application.


    system | 2023-09-30 07:37:26 UTC | #3

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


    This post was migrated from the old Developer Forum.

    ref: 21766