Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I intercept navigation events? #139

Open
vpopescu opened this issue May 30, 2023 · 4 comments
Open

Can I intercept navigation events? #139

vpopescu opened this issue May 30, 2023 · 4 comments
Labels
All OS enhancement New feature or request

Comments

@vpopescu
Copy link

vpopescu commented May 30, 2023

I am trying to see if I can use this library to implement OAUTH in my dotnet application. In order to accomplish this, I need to be able to intercept the redirect responses from the server, because I need to compare them against the OAUTH callback value.

Is there a way to register for events for when the url changes in the browser? Basically the "Navigation Starting" event from WebView2 (https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/navigation-events)

I did notice a WebMessageReceivedHandler available, but (at least on windows) I can't get it to fire to understand what it does.
(EDIT: I now understand this event appears to fire only when something clicked, so it won't help me).

@ottodobretsberger ottodobretsberger added All OS enhancement New feature or request labels Jun 1, 2023
@ottodobretsberger
Copy link
Contributor

We do not currently handle those kind of events (yet). These events would need to be added to the list of events we already do handle, which someone with time and interest could probably accomplish. It is not going to be on our immediate TODO list though.

@rtmann
Copy link

rtmann commented Sep 27, 2023

You can do this, but not using the built in c#/js interop. You need to build a proper webapi and then self host it in the Photino app.

But that's cool, because you can then use all the webapi packages for OAuth.

You don't have to self host it though, you would just be keeping state in w/e is hosting the api.

@MikeYeager
Copy link
Collaborator

If you want to handle the navigation events on the client, that can be done in JavaScript. It's built into many SPA frameworks. Or in pure JavaScript, take a look at https://developer.mozilla.org/en-US/docs/Web/API/Navigation/navigate_event#examples. If you want to handle it on the back end, then @rtmann is correct, you can handle it in the web server. ASP.NET for example, which is small, fast and already included in the deployment. the only place you can't handle it right now is in the WebView control where it raises an event sent back to your .NET app. We may be able to add that at some point.

@rtmann
Copy link

rtmann commented Sep 28, 2023

Yeah, I guess my point was that if you use the web api on the back end, you don't need to handle any navigation events. The packages, configured properly, will just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
All OS enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants