auth0 / auth0-oidc-client-net

OIDC Client for .NET Desktop and Mobile applications
https://auth0.github.io/auth0-oidc-client-net/
Apache License 2.0
84 stars 48 forks source link

What does BrowserResultType.UserCancel indicates? #319

Closed spalmcc closed 7 months ago

spalmcc commented 7 months ago

Checklist

Description

Trying to find "BrowserResultType.UserCancel" indicates?

Reproduction

Just need information

Additional context

Having some issues with integrating Auth0. Need to know what "BrowserResultType.UserCancel"indicates?

auth0-oidc-client-net version

3.5.0

.NET version

.NET6

Platform

Windows

Platform version(s)

.NET6

frederikprijck commented 7 months ago

We generally use UserCancel when the browser is closed before the async operation is completed, see: https://github.com/search?q=repo%3Aauth0%2Fauth0-oidc-client-net%20UserCancel&type=code

spalmcc commented 7 months ago

We generally use UserCancel when the browser is closed before the async operation is completed, see: https://github.com/search?q=repo%3Aauth0%2Fauth0-oidc-client-net%20UserCancel&type=code

Hi, Browser is closed? I have a desktop application (windows forms). I was trying to log out. What you have mentioned is not clear to me.

BrowserResultType browserResult; if (client != null) { browserResult = await client.LogoutAsync(); // browserResult = BrowserResultType.UserCancel (This is what I am getting) }

frederikprijck commented 7 months ago

Yes, we use webview and open the browser to handle login and logout.

For WinForms using WebViewBrowser, see:

However, could it be that you are using WebBrowserBrowser ?

Can you provide a reproduction so i can look into this ?

spalmcc commented 7 months ago

Yes, we use webview and open the browser to handle login and logout.

Can you provide a reproduction so i can look into this ?

I am using webview. The following is the code for logging out:-

BrowserResultType browserResult; if (client != null) { browserResult = await client.LogoutAsync();

}

When I checked the value in "browserResult" I see "BrowserResultType.UserCancel " which is not correct. It should be "BrowserResultType.Success".

So I am trying to understand what exactly is meant by "BrowserResultType.UserCancel " and what can cause this?

frederikprijck commented 7 months ago

I updated my comment above to link to the implementation: https://github.com/auth0/auth0-oidc-client-net/blob/master/src/Auth0.OidcClient.WinForms/WebViewBrowser.cs#L62-L66

As you can seem we use UserCancel in the following case:

 window.Closing += (sender, e) =>
{
    if (!tcs.Task.IsCompleted)
       tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.UserCancel });
};

So as you can see, and as I said, we set UserCancel when the browser is closed before the async operation is completed. If UserCancel is unexpected, I will need to have a reproduction to understand what's going on.

spalmcc commented 7 months ago

Seems I have found the issue. I missed adding "WebViewBrowser.cs" and "WebViewBrowserChromium.cs" classes. I am chekcing the same now.

spalmcc commented 7 months ago

I understand the issue now. My form was closed and after that I was trying to log off thats why I was getting that issue.

spalmcc commented 7 months ago

thanks alot for the clarificaiton and support.