We are using the OAuth implicity authentication to check if the user is logged in or not with .NET platform. The client that we are developing this solution uses an web ERP that will make the “click to call” function.
We found a gap in this solution because the webbrowser does not store the cookie from OAuth and the user can be logged in as user X on Pure cloud Platform and make a call with user Y logged in as user X.
To avoid this gap we are trying to use a Httpclient to make a GET request to redirect us to the Url that contains the access_token parameter. (we are trying to avoid the navigation of a specific browser)
Follow the example below:
var handler = new HttpClientHandler()
{
AllowAutoRedirect = true,
UseCookies = true
};
HttpClient client = new HttpClient(handler)
var request = new HttpRequestMessage(HttpMethod.Get, new Uri("https://login.mypurecloud.com/?rid=frzVqwsGy-cyY90rbVw9VHbnSIOtvqwG3o909c-A4NI"));
HttpResponseMessage result = new HttpResponseMessage();
try
{
result = client.SendAsync(request).Result;
}
catch (Exception ex)
{
}
Do not circumvent the authorization process. The OAuth flow exists for security purposes to require the user to authorize the applications they use. Bypassing this process constitutes abuse of the platform and can result in suspension of your org.
If you need to manage the browser's cookies between sessions, do so by interfacing with the WebBrowser control you're using and allow the user to complete the authorization flow normally.
If you have a hard requirement that the user must not be prompted to authorize an app, you must implement the SAML2 Bearer authorization grant and integrate with an auth provider that is capable of providing SAML assertions without prompting the user.
Trying to execute an auth flow with a web request to avoid showing the browser to the user constitutes circumventing the auth process. Do not do this or you may lose your org.
Good Morning.
Is there a way to log out of the OAuthWebBrowserForm component?
Because when changing User, it remains logged.
Dispose is not doing this.
The Session remains logged in even after Dispose.
That's because the browser is remembering the auth cookie that Genesys Cloud sets. You need to clear the cookies in the browser or navigate to https://login.mypurecloud.com/logout (use your regional URL if different) which will remove the auth cookie.