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

Please upgrade dropbox dependency from 7.x to 8 or 9 #142

Closed
eigood opened this issue May 12, 2021 · 4 comments · Fixed by #163
Closed

Please upgrade dropbox dependency from 7.x to 8 or 9 #142

eigood opened this issue May 12, 2021 · 4 comments · Fixed by #163
Assignees
Labels
bug Something isn't working

Comments

@eigood
Copy link

eigood commented May 12, 2021

I'm getting a 'unable to handle fetch' type error in dropbox.sdk.min.js, which seems to be solved in 8.1.

@eigood eigood added the bug Something isn't working label May 12, 2021
@eigood
Copy link
Author

eigood commented May 12, 2021

Further info; I am migrating from pre-popup usage, and did not have a clientSecret. I am told to use PKCE, which I then set that parameter, and that then leads me to the fetch error.

@eigood
Copy link
Author

eigood commented May 12, 2021

diff --git a/src/dropboxPopup.js b/src/dropboxPopup.js
index 11cea89..dbd1f60 100644
--- a/src/dropboxPopup.js
+++ b/src/dropboxPopup.js
@@ -73,6 +73,7 @@ export default class DropboxPopup {
     this.timeout = timeout || defaultTimeout;
 
     this.authObject = new DropboxAuth({
+      fetch: window.fetch.bind(window),
       clientId: this.clientId,
       clientSecret: this.clientSecret,
     });
@@ -110,6 +111,9 @@ export default class DropboxPopup {
        * @returns {void}
        */
       function handleRedirect(event) {
+        if (event.source !== popupWindow) {
+          return;
+        }
         window.removeEventListener('message', popup.handleRedirect);
 
         const { data } = event;

Basically, there could be multiple child windows(popups or iframes) all sending data back to the parent. So, there needs to be a check that the source window is the one we created. Additionally, the dropbox-sdk that is being required has a bug with fetch, that had to be worked around.

There is also an undocumented requirement that the redirectUri must be specified, and that it must call dispatchMessage(). This needs to be better planned out. I implemented that myself directly in a react-router handler, and call window.opener.postMessage() inside a React.useEffect().

@rogebrd
Copy link
Owner

rogebrd commented Jun 4, 2021

Hello, my apologies on how late this issue took to resolve. I have a diff up to upgrade the Dropbox dependency and have separated out the other issue mentioned to fix the multiple children and the redirectUri/call dispatch message issues here: #164

@rogebrd
Copy link
Owner

rogebrd commented Oct 21, 2021

Hello @eigood, sorry for the delay in fixing the issue but the bug should be fixed as of version v3.1.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants