Skip to content

Commit

Permalink
Upgrade Dropbox dependency to 9.9.0 and support new promise based urls (
Browse files Browse the repository at this point in the history
  • Loading branch information
rogebrd authored Jun 4, 2021
1 parent cfc780e commit 8f18c6d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 5 additions & 7 deletions examples/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@7/dist/polyfill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.3/fetch.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dropbox/dist/Dropbox-sdk.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dropbox-oauth-popup@2.0.1/dist/dropboxPopup.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dropbox-oauth-popup@3.0.0/dist/dropboxPopup.js"></script>
</head>

<body>
<div>
<h1>Dropbox OAuth Popup Window</h1>
<p>
See the Dropbox OAuth Popup Window in action by clicking the run example button.
This example will authenticate with your Dropbox account and use the token to fetch
the current account using the `users.getCurrentAccount` endpoint. (Note, nothing is
saved, this is just a demo.)
See the Dropbox OAuth Popup Window in action by clicking the run example button. This example will authenticate with your Dropbox account and use the token to fetch the current account using the `users.getCurrentAccount` endpoint. (Note, nothing is saved,
this is just a demo.)
</p>
<p>See the code on <a
href="https://github.com/rogebrd/dropbox-oauth-popup/blob/main/examples/browser.html">GitHub</a></p>
<p>See the code on <a href="https://github.com/rogebrd/dropbox-oauth-popup/blob/main/examples/browser.html">GitHub</a></p>
<button onclick="runAuth()">Run Example</button>
<p id="result"></p>
<script>
Expand All @@ -27,6 +24,7 @@ <h1>Dropbox OAuth Popup Window</h1>
clientSecret: 'tbjemcamktbyiy9',
redirectUri: 'https://rogebrd.github.io/dropbox-oauth-popup/tutorial-browser.html'
});

function runAuth() {
document.getElementById("result").innerHTML = "Waiting for auth...";
popup.authUser().then((auth) => {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dropbox-oauth-popup",
"version": "2.0.2",
"version": "3.0.0",
"registry": "npm",
"description": "This is a simple addition built onto the Dropbox SDK that allows for OAuth in the browser to be done via a popup window.",
"homepage": "https://github.com/rogebrd/dropbox-oauth-popup",
Expand Down Expand Up @@ -30,7 +30,7 @@
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"dropbox": "^7.0.0"
"dropbox": "^9.8.0"
},
"browserslist": [
"> 0.25%",
Expand Down Expand Up @@ -58,4 +58,4 @@
"front-end",
"window"
]
}
}
10 changes: 6 additions & 4 deletions src/dropboxPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ export default class DropboxPopup {
});
}

const authUrl = popup.authObject.getAuthenticationUrl(popup.redirectUri, popup.state, 'code', popup.tokenAccessType, popup.scope, popup.includeGrantedScopes, popup.usePKCE);
const popupWindow = window.open(authUrl, windowName, popup.windowOptions);
popupWindow.focus();
window.addEventListener('message', handleRedirect, false);
popup.authObject.getAuthenticationUrl(popup.redirectUri, popup.state, 'code', popup.tokenAccessType, popup.scope, popup.includeGrantedScopes, popup.usePKCE)
.then((authUrl) => {
const popupWindow = window.open(authUrl, windowName, popup.windowOptions);
popupWindow.focus();
window.addEventListener('message', handleRedirect, false);
});
});
}
}

0 comments on commit 8f18c6d

Please sign in to comment.