-
Notifications
You must be signed in to change notification settings - Fork 2
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
Example on using state parameter to preserve query string #318
Comments
@rpwagner – manager.login({ additionalParams: { state: '...' }}); But, taking a look a the internals here, I think you will encounter an However, the I can tell you in the applications we've been using the To do this, where you call Footnotes
|
Thanks @jbottigliero. Session storage was what I also considered. Is this roughly what you're describing? UI.SIGN_IN.addEventListener('click', () => {
/**
* This will redirect the user to the Globus Auth login page.
*/
let queryString = window.location.search;
sessionStorage.setItem("queryString", queryString);
manager.login();
queryString = sessionStorage.getItem("queryString");
window.location.search = queryString;
}); |
Rather than reading the value after Extending that basic example, I think you could do something like... UI.SIGN_IN.addEventListener("click", () => {
/**
* This will redirect the user to the Globus Auth login page.
*/
let queryString = window.location.search;
// You'll set the value before you prompt for login.
sessionStorage.setItem("queryString", queryString);
// Since this will initiate the OAuth redirect, you can't really do any processing afterward.
manager.login();
});
// ...
if (manager.authenticated) {
const queryString = sessionStorage.getItem("queryString");
if (queryString) {
sessionStorage.removeItem("queryString");
// do something;
} |
What problem are you trying to solve?
When a page receives a set of query parameters like
https://example.org/plot.html?file=a.csv
I would like to know the appropriate way to persevere the query stringfile=a.csv
after a login redirect. I believe this is typically handled via thestate
parameter in the OAuth flow, though I could be mistaken.We are using this model to have a single page that view and interact with data from Globus Collections that require access tokens. This way, way can have a single viewer page and load different files based on the query parameters. Examples of doing this for public data are in our Cheap and FAIR template repo (see the view.md and chart.md pages).
Describe the solution you'd like
It would great to have an example like the basic login page that shows how to use the state parameter or other means to do this.
Describe alternatives you've considered
As a workaround, I will try collecting the parameters prior to creating the login manager and calling
manager.handleCodeRedirect()
orlogin()
.The text was updated successfully, but these errors were encountered: