Meteor + React: Storing state after page refresh

Hey guys, I am new to React with Meteor. I am building a simple App where the user will click a button which will redirect them to a 3rd Party site where they will have to grant access to use the app, then they are redirected back and a token is stored in the URL.

First question is… How can I save a state (or is there another approach to this) so that the boolean, hasToken, is false before being sent to the 3rd party app but is then true when the user is returned to my application.

Second question is… Is there a way I can retrieve the token that the 3rd party app sends with me (stored in the URL) when I am redirected from their site back to my site?

Thanks for the help in advance

Doesn’t the 3rd party allow you to use a pop-up instead of a redirect? If so, in the callback to the 3rd party site, just set your component state as success/error. Anyways, it doesn’t matter. You have configured with the 3rd party where to send your user to when the 3rd party task is complete. You can capture the state by looking at the url (you can do this in the router API most likely, or manually) and figuring out of the task was successful, in which case, initiate your component with a successful state. You can do this in your router, the component itself, etc.

Edit: If you don’t know how to get query parameters in your URL, just pass the router object as a prop down to your components, or enable your component to see the router context. You can google “react router context” and “react router prop get query parameters”, or just check out the react-router API/docs.

If you aren’t using react router, adjust your search accordingly, or just start using react router, since you’re using react.