Error on OAuth Connect

I’m having an issue when trying to use OAuth to connect to Dropbox or Google Drive. It gets through the process of going to Google or Dropbox, asking for the user’s consent, then redirects back to my website and shows the error. I’ve searched and tried different ideas for a couple of hours and can’t seem to get to the bottom of it. Anyone have any ideas?

Companion was unable to complete the OAuth process :frowning:
Error: User session is missing or the Provider was misconfigured

Companion log shows this:

companion: 2019-11-20T00:35:03.975Z [error] grant.oauth.error grant.js responded with error: error=Grant%3A%20missing%20session%20or%20misconfigured%20provider

companion server:

#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const companion = require('@uppy/companion')
const app = require('express')()

const DATA_DIR = path.join(__dirname, 'tmp')

app.use(require('body-parser').json())
app.use(require('express-session')({
  secret: 'XXXX',
  resave: false,
  saveUninitialized: false,
}))

app.use((req, res, next) => {
  res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*')
  res.setHeader(
    'Access-Control-Allow-Methods',
    'GET, POST, OPTIONS, PUT, PATCH, DELETE'
  )
  res.setHeader(
    'Access-Control-Allow-Headers',
    'Authorization, Origin, Content-Type, Accept'
  )
  next()
})

const options = {
  providerOptions: {
    dropbox: {
      key: 'XXXX',
      secret: 'XXXX'
    },
    google: {
      key: 'XXXX',
      secret: 'XXXX'
    },
    s3: {
      getKey: (req, filename) =>
        `XXXX/${filename}`,
      key: "XXXX",
      secret: "XXXX",
      bucket: "XXXX",
      region: "us-west-2"
    }
  },
  server: { host: 'XXXX.dxe.io', path: '/uploader/companion', protocol: 'https' },
  filePath: DATA_DIR,
  sendSelfEndpoint: "XXXX.dxe.io/uploader/companion",
  secret: 'XXXX',
  debug: true
}

app.use(companion.app(options))

const server = app.listen(3020, () => {
  console.log('listening on port 3020')
})

companion.socket(server, options)

client:

const Uppy = require('@uppy/core')
const Dashboard = require('@uppy/dashboard')
const AwsS3 = require('./vendor/@uppy/aws-s3')
const Dropbox = require('@uppy/dropbox')
const GoogleDrive = require('@uppy/google-drive')

const uppy = Uppy()
	.use(Dashboard, {
        inline: true,
        target: '#drag-drop-area',
        proudlyDisplayPoweredByUppy: false,
        showLinkToFileUploadResult: false
    })
	.use(AwsS3, {
	  limit: 2,
	  companionUrl: 'https://XXXX.dxe.io/uploader/companion'
	})
	.use(Dropbox, {
	  target: Dashboard,
	  companionUrl: 'https://XXXX.dxe.io/uploader/companion'
	})
	.use(GoogleDrive, {
	  target: Dashboard,
	  companionUrl: 'https://XXXX.dxe.io/uploader/companion'
	})

uppy.on('file-added', async (file) => {
  console.log('Added file', file)
  console.log(uppy.getState())
})

First off, welcome to the forum!

I believe that the issue is because of incorrect configuration; However, because you are getting an error after authenticating, that means you have the key and secret set correctly.

It might be worth a shot to try the standalone server, just to see how it works. I’d assume that the issue is related to the session not working or the provider being misconfigured, as the error states.

Considering that this is an older post, it may have also been a bug that was fixed more recently. In all honesty, I can’t be fully sure of the cause of the issue, but if it is a bug in companion, there’s a good chance that it was fixed already

Hope this helps!
- Andrew

FWIW, the error also shows up if you are using Uppy in multi server mode without having enabled distributed sessions using redis or other alternatives. Auth would happen on one server and subsequent request would go to the other server (round robin being a default) where the session info is not available.