Draft
Conversation
Author
|
The second commit now refactors I don't have a small example yet, but the gist of how to use the broadcast channel pattern described above is that inside the login view (somewhere where let channel = web_sys::BroadcastChannel::new("oauth_response_query").unwrap();
let subscription = gloo_events::EventListener::new(&channel, "message", move |m| {
let m = web_sys::MessageEvent::from(wasm_bindgen::JsValue::from(m));
let data = m.data().as_string().unwrap();
agent.feed_full_redirected(&data);
});
use_effect_with((), |_| {
move || {
drop(subscription);
}
});(with some extra filtering in case there are multiple logins to avoid #43) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #42
This consists of two parts:
I'm starting this as a draft PR already with only the 1st part to get familiar with this project's automated checks.
There's an application pattern that goes with it (have the redirect URI be a simple HTML page with something like
<script>new BroadcastChannel("oauth_response_query").postMessage(window.location.href); window.close();</script>and having an event listener on that channel feed this event into the OAuth2 context), and I do plan to document that somewhere, but I have no clue whether it's best practice to do that way, so this will need to come with some caveat note.