401在Uppy上通过Instagram登录后未经授权

时间:2019-07-31 11:32:18

标签: node.js express

我正在尝试将instagram与Uppy和Companion一起使用。

我遵循这个example来使用Companion和Uppy。

这是来自服务器的代码:

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);

这是选项:

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

这是客户端代码:

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'
    });    

当我单击按钮以连接到Instagram时,我可以登录,但是当它使用uppy auth令牌重定向到发送令牌的网址时,我会获得401未经授权的页面

0 个答案:

没有答案