Skip to content

Instantly share code, notes, and snippets.

View ayanchoudhary's full-sized avatar
🎯
Finding out new fields to explore

Ayan Choudhary ayanchoudhary

🎯
Finding out new fields to explore
View GitHub Profile
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,
@ayanchoudhary
ayanchoudhary / callback.js
Created May 9, 2021 16:31
callback function
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
@ayanchoudhary
ayanchoudhary / session.js
Created May 9, 2021 16:13
session creation
app.use(session({
/* Change this to your own secret value */
secret: 'this-is-secret',
resave: true,
saveUninitialized: true,
cookie: {
secure: false,
maxAge: 6000000
}
}));
@ayanchoudhary
ayanchoudhary / polling.js
Created May 9, 2021 16:02
polling function
// 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) {
@ayanchoudhary
ayanchoudhary / manifest.json
Created May 9, 2021 15:44
oauth workflow manifest
{
"id": "com.example.adobe.oauth-workflow",
"name": "oauth-workflow-sample",
"version": "1.0.0",
"main": "index.html",
"host": [
{
"app": "PS",
"minVersion": "22.0.0"
}