files_external_dropbox icon indicating copy to clipboard operation
files_external_dropbox copied to clipboard

App thinks it is using Google Oauth

Open ConorIA opened this issue 7 years ago • 28 comments

When I enter the app key and secret, I get taken to a Google Drive OAUTH page with a 404 error.

ezgif com-video-to-gif

ConorIA avatar Oct 06 '17 20:10 ConorIA

I can confirm this. When I tried granting access again it finally worked.

notjoe avatar Oct 06 '17 21:10 notjoe

I've tried reinstalling, adding as an admin or as a regular user, creating different Dropbox API credentials. All to no avail.

ConorIA avatar Oct 09 '17 13:10 ConorIA

Just thought I'd update here. I tried replacing the Google portions of the URL with the Dropbox info, that is, changing

https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=https%3A%2F%2F**my.nextcloud.url**%2Fsettings%2Fadmin%2Fexternalstorages&client_id=**clientID**&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&access_type=offline&approval_prompt=force

to

https://www.dropbox.com/oauth2/authorize?response_type=code&redirect_uri=https%3A%2F%2F**my.nextcloud.url**%2Fsettings%2Fadmin%2Fexternalstorages&client_id=**clientID**

but it returns an error:

"Step 2 failed. Exception: Error fetching OAuth2 access token, message: 'invalid_client: The OAuth client was not found.'"

EDIT: Changing code to token also doesn't work.

ConorIA avatar Oct 19 '17 18:10 ConorIA

Same here :( Makes me sad.... Did someone get it to work?

Teyro avatar Oct 19 '17 19:10 Teyro

Yepp, same here...

ColdSphinX avatar Oct 20 '17 15:10 ColdSphinX

I wonder if we have anything in common... I run Nextcloud via Docker using Wonderfalls's image. Not sure if that has anything to do with the error.

ConorIA avatar Oct 20 '17 19:10 ConorIA

same issue here with "plain" NextCloud 12.0.3. Files_external and Files_external_dropbox is enabled and as soon as i click on the grant button i get redirected to a google (?!) OAuth2 page with an access denied. Any update on this issue?

kosli avatar Oct 22 '17 09:10 kosli

It seems to be some kind of race condition in the JS code. The button "Grant access" triggers both the Dropbox and Google Drive JS handlers. Most of the time Google Drive wins, and performs the redirect to the wrong URL. I was able to get the correct URL by stepping through the code with the JS debugger. Then I manually copied it into a new browser tab and it worked.

zeitgeist87 avatar Oct 28 '17 13:10 zeitgeist87

I'm seeing an error on the console:

Loading failed for the <script> with source “https://cloud.conr.ca/apps/files_external_dropbox/js/dropbox.js?v=2ce5bcf75f701fbcfd534faf8b4fda50-36”.
externalstorages:71
Content Security Policy: The page’s settings blocked the loading of a resource at self (“script-src 'nonce-YjhSNDhRY3VlK2gwbnVLdDRGSUR6OS9lekZ2anpSVXRkZlFmUFQ0Kyswdz06SWFVL3VYUkRPS3d4KzdUTGt4UTIvb3lHL1RhWGgzbG5ScFZGQkgxTG5Dcz0=' 'unsafe-eval'”). Source: onfocusin attribute on DIV element.

ConorIA avatar Oct 31 '17 03:10 ConorIA

I've managed to get past the grant step but it won't download and I'm getting a ton of errors.

Could not load storage: "Unable to get backend for files_external_dropbox"

Exception: Creating \OCA\Files_external_dropbox\Storage\Dropbox storage failed
--

Anyway this is how I got this far.. When pressing the grant button if it redirects you to google. Copy and paste this link instead:

https://www.dropbox.com/oauth2/authorize?response_type=code&redirect_uri=https%3A%2F%2F**www.YOURDOMAIN.com**%2Findex.php%2Fsettings%2Fadmin%2Fexternalstorages&client_id=**YOURCLIENTID**&scope=&force_reapprove=true Replace www.YOURDOMAIN.com with your domain and YOURCLIENTID with your client ID

Jonthe838 avatar Nov 01 '17 10:11 Jonthe838

@Jonthe838, I get Step 2 failed. Exception: Error fetching OAuth2 access token, message: 'invalid_client: The OAuth client was not found.' when I try your URL workaround. 😞

ConorIA avatar Nov 01 '17 16:11 ConorIA

@ConorIA That's the same error as you posted before. Double check your Client ID and the URL that you've entered on Dropbox's website for your app, it seems as something doesn't match. Where do you have your Nexcloud installation? What is your file path?

I managed to get it "working" again following the steps that I did earlier today. I still can't download anything but yeah.

One problem that I saw a lot of people having over at the OwnCloud forum was that they tried to copy the Client Secret / key which yielded problems. I don't think that's the case here but its worth noting.

Jonthe838 avatar Nov 01 '17 16:11 Jonthe838

@Jonthe838, no such luck. I have no idea what I'm doing wrong. I guess the first thing to rule out: the ClientID is the "App key", right?

ConorIA avatar Nov 01 '17 17:11 ConorIA

@ConorIA Correct, that is what I used at least. Do your site have SSL? If not, change my link to http. Also what type of access have you given your app? Have you installed all of the dependencies?

I mean I'm fumbling in the dark here, all I did was a little reading up on the documentation for the API v2 and compared it to the link that the "grant button" provided me with and worked my way through it until it matched the examples on dropbox.com and it took me back to my Nextcloud server.

Jonthe838 avatar Nov 01 '17 18:11 Jonthe838

@Jonthe838, everything seems to be in order. I've even tried creating another Dropbox API app, but to no avail. Anyway, I will wait it out for now. Thanks for your support!

ConorIA avatar Nov 01 '17 21:11 ConorIA

@ConorIA I had exactly the same problem and as said by @Jonthe838 I just typed my secret key instead of copy/pasting it and... it worked! Sadly, when I go to the files page and click on external storage and the name of my mounting point, then it starts running forever and I can't see any dropbox content...

Edit: well, you just need to be patient, I now can see the files, but as noted in another issues, all files and directory names are lower case...

leolivier avatar Nov 05 '17 14:11 leolivier

This is also true for me on nc 12.03. I also tried to type instead of paste both key and secret but to no avail. In my case, I also see #11 at the same time.

darkmattercoder avatar Nov 06 '17 20:11 darkmattercoder

Please retry with latest master if you're running into this issue

icewind1991 avatar Nov 09 '17 14:11 icewind1991

I'm still getting a Google OAuth page.

ConorIA avatar Nov 09 '17 17:11 ConorIA

With the latest master, it indeed works for me. I had to re-add the app on the dropbox website and also I saw a notification popup two or three times about failed Oauth2 verification though, before the external storage became green.

darkmattercoder avatar Nov 09 '17 18:11 darkmattercoder

My issue with the client not being found made me think to check the db:

MariaDB [nextcloud]> SELECT * FROM oc_external_mounts;    
+----------+--------------+------------------------+----------------+----------+------+
| mount_id | mount_point  | storage_backend        | auth_backend   | priority | type |
+----------+--------------+------------------------+----------------+----------+------+
|       11 | /GoogleDrive | googledrive            | oauth2::oauth2 |      100 |    1 |
|       20 | /Dropbox     | files_external_dropbox | oauth2::oauth2 |      100 |    1 |
+----------+--------------+------------------------+----------------+----------+------+
2 rows in set (0.00 sec)

MariaDB [nextcloud]> SELECT * FROM oc_external_config;    
+-----------+----------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| config_id | mount_id | key           | value                                                                                                                                                                                                                                                                              |
+-----------+----------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|        43 |       11 | configured    | true                                                                                                                                                                                                                                                                               |
|        44 |       11 | client_id     | XXXX.apps.googleusercontent.com                                                                                                                                                                                                           |
|        45 |       11 | client_secret | XXXX                                                                                                                                                                                                                                                           |
|        46 |       11 | token         | {"access_token":"XXXX","expires_in":3600,"refresh_token":"XXXX","token_type":"Bearer","created":1507322628} |
|        79 |       20 | configured    | false                                                                                                                                                                                                                                                                              |
|        80 |       20 | client_id     | XXXX                                                                                                                                                                                                                                                                    |
|        81 |       20 | client_secret | XXXX                                                                                                                                                                                                                                                                    |
|        82 |       20 | token         | false                                                                                                                                                                                                                                                                              |
+-----------+----------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
8 rows in set (0.00 sec)

MariaDB [nextcloud]> 


ConorIA avatar Nov 09 '17 19:11 ConorIA

By manually typing App key and App secret, I got the authorization process to finish, but syncing does not work. The root directory of my Dropbox got synced, but nothing else.

The log is flooded with 'Could not load storage: "Unable to get backend for files_external_dropbox"', which might be because of these to entries from around the time I set up the authorization:

  • Narrowing occurred during type inference. Please file a bug report on bugs.php.net at /var/www/nextcloud/lib/composer/composer/ClassLoader.php#444

  • Exception: Creating \OCA\Files_external_dropbox\Storage\Dropbox storage failed

Sitenote: "Function mcrypt_create_iv() is deprecated at /var/www/nextcloud/apps/files_external_dropbox/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Security/McryptRandomStringGenerator.php#47"

johenning avatar Dec 20 '17 10:12 johenning

People are reporting various problems is this issue, does anyone still experience the original "thinks it's google drive" issue with latest master?

icewind1991 avatar Dec 21 '17 13:12 icewind1991

Yes. I've never had any luck getting past the auth.

ConorIA avatar Dec 21 '17 14:12 ConorIA

@ConorIA

Yes. I've never had any luck getting past the auth.

Are you having the problem described in the original issue (being redirected to google auth instead of dropbox) or something else.

icewind1991 avatar Feb 07 '18 11:02 icewind1991

I was running into the Google oAuth issue. That said, I hadn't tried to use this app since NC12. On NC13 now, I am hitting another wall. I just followed the instructions in the readme to a tee and yet am getting a blank external storage screen and the error: Could not find resource file "/apps/files_external/js/../../files_external_dropbox/js/dropbox.js"

ConorIA avatar Feb 07 '18 19:02 ConorIA

@ConorIA I think this issue occurs when the app is installed in a secondary app folder (e.g. the custom_apps folder when using the docker image). As a workaround, you could copy files_external_dropbox from custom_apps/ into apps/. Once the dropbox folder is configured you can delete the app from apps/ (or let Nextcloud do it at the next upgrade).

simonbru avatar May 15 '18 09:05 simonbru

@simonbru. That's done the trick. Thanks!

ConorIA avatar May 15 '18 20:05 ConorIA