Pārlūkot izejas kodu

Revert "companion: change oauth access token transport method"

This reverts commit 49420675137616f7f937e7b3bb2a1e63513121ab.
Ifedapo Olarewaju 6 gadi atpakaļ
vecāks
revīzija
36604a2ed5

+ 0 - 1
CHANGELOG.md

@@ -107,7 +107,6 @@ PRs are welcome! Please do open an issue to discuss first if it's a big feature,
 - [x] @uppy/companion: investigate 423 and 500 issues with React Native + Url plugin when pause/resuming an upload
 - [x] companion: remove deprecated "authorized" endpoint
 - [x] companion: remove fallback `UPPYSERVER_*` env options
-- [x] companion: change OAuth access token transport
 
 ## 1.0 Goals
 

+ 0 - 3
packages/@uppy/companion/src/config/grant.js

@@ -2,20 +2,17 @@
 module.exports = () => {
   return {
     google: {
-      transport: 'session',
       scope: [
         'https://www.googleapis.com/auth/drive.readonly'
       ],
       callback: '/drive/callback'
     },
     dropbox: {
-      transport: 'session',
       authorize_url: 'https://www.dropbox.com/oauth2/authorize',
       access_url: 'https://api.dropbox.com/oauth2/token',
       callback: '/dropbox/callback'
     },
     instagram: {
-      transport: 'session',
       callback: '/instagram/callback'
     }
   }

+ 2 - 1
packages/@uppy/companion/src/server/controllers/callback.js

@@ -17,7 +17,8 @@ module.exports = function callback (req, res, next) {
     req.uppy.providerTokens = {}
   }
 
-  req.uppy.providerTokens[providerName] = req.session.grant.response.access_token
+  // TODO see if the access_token can be transported in a different way that url query params
+  req.uppy.providerTokens[providerName] = req.query.access_token
   logger.debug(`Generating auth token for provider ${providerName}.`)
   const uppyAuthToken = tokenService.generateToken(req.uppy.providerTokens, req.uppy.options.secret)
   return res.redirect(req.uppy.buildURL(`/${providerName}/send-token?uppyAuthToken=${uppyAuthToken}`, true))

+ 1 - 0
packages/@uppy/companion/src/standalone/helper.js

@@ -28,6 +28,7 @@ const getConfigFromEnv = () => {
   const validHosts = domains ? domains.split(',') : []
 
   return {
+    // TODO: Rename providerOptions to providers.
     providerOptions: {
       google: {
         key: process.env.COMPANION_GOOGLE_KEY,

+ 0 - 6
packages/@uppy/companion/test/mockserver.js

@@ -5,12 +5,6 @@ const session = require('express-session')
 var authServer = express()
 
 authServer.use(session({ secret: 'grant', resave: true, saveUninitialized: true }))
-authServer.all('*/callback', (req, res, next) => {
-  req.session.grant = {
-    response: {access_token: 'fake token'}
-  }
-  next()
-})
 authServer.all('/drive/send-token', (req, res, next) => {
   req.session.grant = {
     state: 'non-empty-value' }