This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const dropboxApiKey = "YOUR-DROPBOX-API-KEY"; | |
| const dropboxApiSecret = "YOUR-DROPBOX-SECRET"; | |
| const publicUrl = "http://localhost:8000"; | |
| try { | |
| if (module) { | |
| module.exports = { | |
| dropboxApiKey: dropboxApiKey, | |
| dropboxApiSecret: dropboxApiSecret, | |
| publicUrl: publicUrl, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.get('/callback', function (req, res) { | |
| /* Retrieve authorization code from request */ | |
| let code = req.query.code; | |
| let requestId = req.query.state; | |
| /* Set options with required paramters */ | |
| let requestOptions = { | |
| uri: `https://api.dropboxapi.com/oauth2/token?grant_type=authorization_code&code=${code}&client_id=${dropboxApiKey}&client_secret=${dropboxApiSecret}&redirect_uri=${publicUrl}/callback`, | |
| method: 'POST', | |
| json: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.use(session({ | |
| /* Change this to your own secret value */ | |
| secret: 'this-is-secret', | |
| resave: true, | |
| saveUninitialized: true, | |
| cookie: { | |
| secure: false, | |
| maxAge: 6000000 | |
| } | |
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // XHR helper function | |
| function xhrRequest(url, method) { | |
| return new Promise((resolve, reject) => { | |
| const req = new XMLHttpRequest(); | |
| req.timeout = 6000; | |
| req.onload = () => { | |
| if (req.status === 200) { | |
| try { | |
| resolve(req.response); | |
| } catch (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "id": "com.example.adobe.oauth-workflow", | |
| "name": "oauth-workflow-sample", | |
| "version": "1.0.0", | |
| "main": "index.html", | |
| "host": [ | |
| { | |
| "app": "PS", | |
| "minVersion": "22.0.0" | |
| } |