react-oauth-popup | ️ React component for doing oAuth popups | OAuth library
kandi X-RAY | react-oauth-popup Summary
kandi X-RAY | react-oauth-popup Summary
️ React component for doing oAuth popups
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-oauth-popup
react-oauth-popup Key Features
react-oauth-popup Examples and Code Snippets
Community Discussions
Trending Discussions on react-oauth-popup
QUESTION
I'm interested in how to implement OAuth in React using popup (window.open
).
For example I have:
mysite.com
— this is where I open the popup.passport.mysite.com/oauth/authorize
— popup.
The main question is how to create connection between window.open
(popup) and window.opener
(as it's known the window.opener is null due to cross-domain security therefore we can't use it anymore).
⇑
window.opener
is removed whenever you navigate to a different host (for security reasons), there is no way around it. The only option should be doing the payment in a frame if it is possible. The top document needs to stay on the same host.
Scheme:
Possible solutions:
- Check an opened window using
setInterval
described here. - Using cross-storage (not worth it imho ).
So what's the best recommended approach in 2019?
...Wrapper for React - https://github.com/Ramshackle-Jamathon/react-oauth-popup
ANSWER
Answered 2019-Nov-14 at 19:59I once encounter an issue on my oauth login flow with window.open/window.opener bug on ms-edge
My flow before this issue was
- On login button click open a popup
- After successful login the oauth app redirect to my domain's page
- Then i call a function of the parent window from with in the popup (window.opener.fn) with data from oauth response and the parent window then close the child popup window
My flow after this issue was
- On login button click open a popup
- Create a setinterval in case (window.opener is undefined)
- After successful login the oauth app redirect to my domain's page
- Check if window.opener is available then do #3 from the above flow and clearInterval
- If window.opener is not available then since i am on my domains page i try to set localstorage and try to read the localstorage from inside the setInterval function in parent window then clear the localstorage and setInterval and proceed.
- (for backward compatibility) If localstorage is also not available then set a client side cookie with the data with a short expiry (5-10 sec) time and try to read the cookie (document.cookie) inside the setInterval function in parent window and proceed.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-oauth-popup
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page