transloadit / uppy-server

[DEPRECATED] 'Uppy Server' was renamed to 'Companion' and lives inside the Uppy repo no
https://github.com/transloadit/uppy/tree/master/packages/%40uppy/companion
MIT License
114 stars 27 forks source link

Google Drive provider not found in standalone mode #41

Closed elluminatte closed 6 years ago

elluminatte commented 6 years ago

Hi there

Looks like Google Drive integration doesnt work properly in standalone mode.

Preconditions:

  1. uppy-server 0.9.0 running in docker container (standalone mode)
  2. went to Google Drive tab, press Authenticate button
  3. Google login form displayed - entered credentials and logged in

1

Expected result:

  1. Returned to my site, Drive explorer is opened

Actual result:

  1. Facing error

2

  1. Message from docker container

3

(uppy_1  | uppy: Invalid provider options detected. Provider will not be loaded
uppy_1  |  Error: Not Found
uppy_1  |     at app.use (/app/src/standalone/index.js:110:15)
uppy_1  |     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
uppy_1  |     at trim_prefix (/app/node_modules/express/lib/router/index.js:312:13)
uppy_1  |     at /app/node_modules/express/lib/router/index.js:280:7
uppy_1  |     at Function.process_params (/app/node_modules/express/lib/router/index.js:330:12)
uppy_1  |     at next (/app/node_modules/express/lib/router/index.js:271:10)
uppy_1  |     at /app/node_modules/express/lib/application.js:232:9
uppy_1  |     at /app/node_modules/express/lib/router/index.js:618:15
uppy_1  |     at next (/app/node_modules/express/lib/router/index.js:256:14)
uppy_1  |     at next (/app/node_modules/express/lib/router/route.js:121:14) 
uppy_1  | ::ffff:172.20.0.3 - - [02/Dec/2017:10:50:55 +0000] "GET /google/redirect?state)
  1. Figured out that error happens in lib/server/provider/index.js:
    • if (providers[providerName] ...) - provider name is google (according action name is URL, see first attach)
    • there is no providers['google'] element, but there is providers['drive']

So please fix this or tell me what am i doing wrong.

Regards, Nikolay

ifedapoolarewaju commented 6 years ago

@elluminatte I misunderstood your comment earlier, and mistook your issue for something else.

The issue you are experiencing is most likely due to some inconsistent configuration. Do you mind sharing what your config is like? You can mask out important credentials :)

elluminatte commented 6 years ago

@ifedapoolarewaju of course, this is my config:

UPPYSERVER_SECRET=blabla
UPPYSERVER_DOMAIN=images.nikolay.office.blabla.ru
UPPYSERVER_DATADIR=app/storage

UPPYSERVER_PROTOCOL=https

UPPYSERVER_GOOGLE_KEY=blabla.apps.googleusercontent.com
UPPYSERVER_GOOGLE_SECRET=blabla

UPPYSERVER_INSTAGRAM_KEY=blabla
UPPYSERVER_INSTAGRAM_SECRET=blabla

UPPYSERVER_OAUTH_DOMAIN=images.nikolay.office.blabla.ru

DOMAIN_UPPY=images.nikolay.office.blabla.ru

Please keep in mind that instagram provider works perfect, i'm facing issues only with Google Drive

ifedapoolarewaju commented 6 years ago

If this issue is only with google drive then it is most likely you set the wrong redirect_uri on your google drive dashboard. Can you confirm if that’s the case?

Sent from my iPhone

On 2 Dec 2017, at 2:38 PM, Salov Nikolay notifications@github.com wrote:

@ifedapoolarewaju of course, this is my config:

UPPYSERVER_SECRET=blabla UPPYSERVER_DOMAIN=images.nikolay.office.optimuspro.ru UPPYSERVER_DATADIR=app/storage

UPPYSERVER_PROTOCOL=https

UPPYSERVER_GOOGLE_KEY=blabla.apps.googleusercontent.com UPPYSERVER_GOOGLE_SECRET=blabla

UPPYSERVER_INSTAGRAM_KEY=blabla UPPYSERVER_INSTAGRAM_SECRET=blabla

UPPYSERVER_OAUTH_DOMAIN=images.nikolay.office.optimuspro.ru

DOMAIN_UPPY=images.nikolay.office.optimuspro.ru Please keep in mind that instagram provider works perfect, i'm facing issues only with Google Drive

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

elluminatte commented 6 years ago

@ifedapoolarewaju but i don't specify the redirect_uri in API console. i only specify the authorized URIs list. I've added the URI, that is generated by uppy server in this list. So i think that redirect uri is controlled by uppy-server, am i wrong?

elluminatte commented 6 years ago

@ifedapoolarewaju i see this string in library test file (test/tests/provider-manager.js):

_expect(grantConfig.google.redirecturi).toBe('http://domain.com/google/redirect')

This is the URI, that i see in browser address string, then i think that it's not really Drive Dashboard tuning issue.

ifedapoolarewaju commented 6 years ago

I am currently responding from my mobile so I’m unable to do much, one suggestion would be to drop the UPPYSERVER_OAUTH_DOMAIN config if you don't have multiple instances of your server running.

Perhaps there’s a bug somewhere in the Multiple instance redirect channeling for google drive (I can’t confirm till I get to my machine) but I know for sure that it works right for single instance setting.

So simply drop the UPPYSERVER_OAUTH_DOMAIN config and see if it works

Sent from my iPhone

On 2 Dec 2017, at 2:57 PM, Salov Nikolay notifications@github.com wrote:

@ifedapoolarewaju i see this string in library test file (test/tests/provider-manager.js):

expect(grantConfig.google.redirect_uri).toBe('http://domain.com/google/redirect')

This is the URI, that i see in browser address string, then i think that it's not really Drive Dashboard tuning issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

elluminatte commented 6 years ago

LOL i've just figured out the same issue.

There are these lines in src/server/provider/index.js file:

if (oauthDomain) {
        grantConfig[providerName].redirect_uri = `${server.protocol}://${oauthDomain}/${providerName}/redirect`
}

Then redirectUrl becomes https://blabla/google/redirect, and uppy tries to find google provider, while it should be drive.

I've temporary removed UPPYSERVER_OAUTH_DOMAIN setting, described issue has been resolved. But now nothing happens after auth - i login with google account, then i was redirected to my site but button on Uppy Dashboard says "PLEASE AUTHENTICATE WITH GOOGLE DRIVE TO SELECT FILES". Again and again... No errors in console or in docker log.

Could you check that Google Drive provider really works with latest uppy-server release?

ifedapoolarewaju commented 6 years ago

Does instagram work with this change?

Sent from my iPhone

On 2 Dec 2017, at 3:17 PM, Salov Nikolay notifications@github.com wrote:

LOL i've just figured out the same issue.

There are these lines in src/server/provider/index.js file:

if (oauthDomain) { grantConfig[providerName].redirect_uri = ${server.protocol}://${oauthDomain}/${providerName}/redirect } Then redirectUrl becomes https://blabla/google/redirect, and uppy tries to find google provider, while it should be drive.

I've temporary removed UPPYSERVER_OAUTH_DOMAIN setting, described issue has been resolved. But now nothing happens after auth - i login with google account, then i was redirected to my site but button on Uppy Dashboard says "PLEASE AUTHENTICATE WITH GOOGLE DRIVE TO SELECT FILES". Again and again... No errors in console or in docker log.

Could you check that Google Drive provider really works with latest uppy-server release?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

elluminatte commented 6 years ago

@ifedapoolarewaju yep. Instagram still works properly

ifedapoolarewaju commented 6 years ago

Ok, my hands are a bit tied right now, let me suggest a more reasonable solution in a couple hours when I get back to my machine.

Is that ok?

Sent from my iPhone

On 2 Dec 2017, at 3:29 PM, Salov Nikolay notifications@github.com wrote:

@ifedapoolarewaju yep. Instagram still works properly

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

elluminatte commented 6 years ago

@ifedapoolarewaju no problem! This is opensource project anyway lol. Thank you!

ifedapoolarewaju commented 6 years ago

@elluminatte did you make any progress with this? I can confirm that the GoogleDrive provider is working fine as at the last release. Maybe there's still something up with your configuration? Did you restart the docker instance after updating the config?

PS. This difficulty in debugging would no longer be so by the next release, as I have added a debug flag functionality, that would help one get more detailed logs on every level/layer the server routing process passes through.

elluminatte commented 6 years ago

@ifedapoolarewaju hi have not figured out anything new. looks like google authorization finishes successfully, but uppy doesnt see auth state - after auth with google dashboard says: "PLEASE AUTHENTICATE WITH GOOGLE DRIVE TO SELECT FILES". If i click button, i'm being immediately redirected to site (so i think auth is completed). Again and again. May be reason is related with Uppy frontend code? I'm using bundled version from your CDN

elluminatte commented 6 years ago

@ifedapoolarewaju this is network log - Demo on your site VS uppy on my site. I see requesting /drive/root in demo, vs 3 ones of /authorize on my site

4

5

ifedapoolarewaju commented 6 years ago

@elluminatte I am unable to reproduce this issue on my end, since instagram provider works for you, this is most likely an issue with your google provider set up.

Can you confirm you have a URL of the form <protocol>://<yourhost>/connect/google/callback as authorized url on your google api console?

This is usually what you would set if you are not making use of the UPPYSERVER_OAUTH_DOMAIN option

elluminatte commented 6 years ago

@ifedapoolarewaju hi. yes, URL is confirmed in console of course

ifedapoolarewaju commented 6 years ago

Hmm, now I'm running out of ideas, what version of the uppy client are you running?

elluminatte commented 6 years ago

@ifedapoolarewaju i'm using latest v 0.21.0

elluminatte commented 6 years ago

@ifedapoolarewaju this was not really uppy issue. I've added console.log(err) in server/controllers/authorized.js, then i've seen the error reason: "Access Not Configured. Drive API has not been used in project xxxx before or it is disabled". So after enabling it works OK.

Anyway could you please implement error loging for similar situations in future - as we have seen it's very hard to debug