Hello,
I’m trying to use instagram with Uppy and Companion.
I followed this example to use Companion and Uppy.
This is the code from the server:
const env = require('./src/env/env');
const options = require('./src/uppy/uppy')();
const express = require('express');
const session = require('express-session');
const bodyParser = require('body-parser');
const companion = require('@uppy/companion');
const app = express();
app.use(bodyParser.json());
app.use(session({
secret: env.secret,
resave: true,
saveUninitialized: true
}));
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Authorization, Origin, Content-Type, Accept');
res.setHeader('Access-Control-Allow-Credentials', 'true');
next();
});
app.get('/', (req, res) => {
res.setHeader('Content-Type', 'text/plain')
res.send('Up and running!');
});
app.use(companion.app(options));
companion.socket(app.listen(env.port), options);
console.log("Up and running at: " + env.url);
This is the options:
providerOptions: {
// google: {
// key: env.googleDrive.key,
// secret: env.googleDrive.secret
// },
instagram: {
key: env.instagram.key,
secret: env.instagram.secret
},
},
server: {
host: env.url,
protocol: 'http'
},
filePath: env.filePath,
secret: env.uppy.secret,
debug: env.isDebug,
sendSelfEndpoint: env.url
This is the client code:
let uppy = this.Uppy.Core({
autoProceed: false,
allowMultipleUploads: false,
inline: true,
debug: true
})
.use(this.Uppy.Dashboard, {
inline: true,
target: '#t-imagem-content'
})
.use(this.Uppy.Instagram, {
target: this.Uppy.Dashboard,
companionUrl: 'http://localhost:4333',
})
.use(this.Uppy.XHRUpload, {
endpoint: 'https://localhost:44304/api/Settings/UploadProfile',
method: 'post',
formData: true,
fieldName: 'file'
});
When i click on the button to connect to Instagram, i can do the login, but when it redirects to the send-token url with the uppy auth token, i get the 401 Unauthorized page