icewind1991 / files_external_dropbox

External Storage backend for Dropbox
GNU Affero General Public License v3.0
55 stars 19 forks source link

App thinks it is using Google Oauth #3

Open ConorIA opened 7 years ago

ConorIA commented 7 years ago

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

notjoe commented 7 years ago

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

ConorIA commented 7 years ago

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

ConorIA commented 7 years ago

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.

Teyro commented 7 years ago

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

ColdSphinX commented 7 years ago

Yepp, same here...

ConorIA commented 7 years ago

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.

kosli commented 7 years ago

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?

zeitgeist87 commented 6 years ago

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.

ConorIA commented 6 years ago

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.
Jonthe838 commented 6 years ago

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

ConorIA commented 6 years ago

@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. 😞

Jonthe838 commented 6 years ago

@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.

ConorIA commented 6 years ago

@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?

Jonthe838 commented 6 years ago

@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.

ConorIA commented 6 years ago

@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!

leolivier commented 6 years ago

@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...

darkmattercoder commented 6 years ago

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.

icewind1991 commented 6 years ago

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

ConorIA commented 6 years ago

I'm still getting a Google OAuth page.

darkmattercoder commented 6 years ago

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.

ConorIA commented 6 years ago

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]> 
johenning commented 6 years ago

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:

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"

icewind1991 commented 6 years ago

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

ConorIA commented 6 years ago

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

icewind1991 commented 6 years ago

@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.

ConorIA commented 6 years ago

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"

simonbru commented 6 years ago

@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).

ConorIA commented 6 years ago

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