openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.7k forks source link

[Dropbox IO] Dropbox API app disabled #4588

Closed joakimolsson closed 7 years ago

joakimolsson commented 8 years ago

Expected Behavior

Current Behavior

The dropbox integration fails with error: [WARN ] [d.internal.DropboxSynchronizer] - Synchronizing data with Dropbox throws an exception: unexpected HTTP status code: 403: {"api_error": true, "user_error": "This app is currently disabled.", "error": "This app is currently disabled."}

I asked the dropbox team and this is what they answered:

Hi Joakim,

Thanks for writing this in. This error indicates that the Dropbox API app has been disabled, either by the owner of the app disabling the app itself, or by the owner deleting their account.

Please reach out to the developer/owner of the app for help with this issue.

If the developer needs help with their app, they can open a ticket with us at:

https://www.dropbox.com/developers/contact

Possible Solution

I don't know who is the maintainer for the dropbox API app, but it seems that the solution lies with him/her.

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

watou commented 8 years ago

It appears that the wiki page is incomplete, because it does not document the keys for configuration appkey and appsecret (see the code here). The bundle instead relies on default values, but your report strongly suggests the default values are no longer valid.

If you were to register your own Dropbox app, thereby producing your own appkey and appsecret values for openhab.cfg:

dropbox:appkey=YOUR_VALUE
dropbox:appsecret=YOUR_VALUE

then you would most likely get past this issue.

Part of the fix for this issue would be to document how to create your own app for Dropbox and supply the values in the configuration. Another part of the fix would be to eliminate default values altogether, so that no user is dependent on a third-party app for the integration to work. What are your thoughts?

teichsta commented 8 years ago

@watou is right but there was also a general app being "owned" by our openHAB user. Don't know what happened to it. Will have a look at it tomorrow …

update: it seems that the "official" openHAB app had been linked to my personal Dropbox-Account which i deleted last week. Unfortunately Dropbox-Wide there can only be one "App" named openHAB and somebody took the name meanwhile.

Does any of the guys reading this thread "own" the openHAB app? Would be great if you could release the name again and give me sign. Thanks!

pbomark commented 8 years ago

After messing with creating my own app and supplying it's key and secret, I'm being stonewalled by the call to DbxRequestConfig with a fixed string as application name. A possible solution is to add a field for that string in the config. Something like:

dropbox:clientidentifier =MyOwnOpenHabDropboxSyncApp
dropbox:clientversion=1.0

Should allow users to create their own apps without touching code.

Edit: If I copy my own app id into a request url and try to enter the response code this is what I get: BadRequest: {"error_description": "code is associated with a different app key", "error": "invalid_grant"}

watou commented 8 years ago

@pbomark are you saying that if the bundle accepted and used all of the below, you believe you would have success?

dropbox:appkey=YourCustomAppKey
dropbox:appsecret=YourCustomAppSecret
dropbox:clientid=YourCustomAppName/1.0

(see the DbxRequestConfig JavaDoc for how clientid would be used)

I will submit a PR if you think that would work.

...please try this test JAR using the example above of supplying clientid.

pbomark commented 8 years ago

Looking at how the request URL is built, and the fact that tje URL is not changing even with a different appkey, it is probably comming from the app name?

watou commented 8 years ago

Looking at how the request URL is built, and the fact that tje URL is not changing even with a different appkey, it is probably comming from the app name?

I'm afraid I don't understand your comment. Is it that you are specifying config values but they aren't being respected no matter what, and that you still see the default values being used?

pbomark commented 8 years ago

line 153

private final static DbxRequestConfig requestConfig = new DbxRequestConfig("openHAB/1.0",
            Locale.getDefault().toString());

line 195

public void startAuthentication() throws DbxException {
        DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(requestConfig, appInfo);
        String authUrl = webAuth.start();

      logger.info("#########################################################################################");
        logger.info("# Dropbox-Integration: U S E R   I N T E R A C T I O N   R E Q U I R E D !!");
        logger.info("# 1. Open URL '{}'", authUrl);
        logger.info("# 2. Allow openHAB to access Dropbox");
        logger.info("# 3. Paste the authorisation code here using the command 'finishAuthentication \"<token>\"'");
        logger.info("#########################################################################################");
    }

Try changing the appkey value in the config and see if the authURL is any different. To me it's not, which makes me think that DbxWebAuthNoRedirect actually returns the authURL based on the DbxRequestConfig content, not the appInfo.

watou commented 8 years ago

This is possibly due to the fact that appInfo and requestConfig are statically initialized and so don't consider the config values. If so, this class could use some refactoring. Your opinion?

ovomaltin commented 7 years ago

@teichsta Any news on this issue. I am also getting the warning.

Thanks, OvO

svenschreier commented 7 years ago

i can replace the appkey manually the appkey at the generated key. but now i have the big problem to send the generated auth-id via finishAuthentication osgi-command to my openhab2 installation. maybe this is a showstopper for dropbox-io to openhab2?

9037568 commented 7 years ago

I have a solution which allows this to work after creating a new app by using the generated access token.

oauth

I'll post details later...

9037568 commented 7 years ago

Here's the code change I would propose, and a test jar.

To create an app on dropbox and get the access token, follow this tutorial. The generated access token can then be copied and pasted into openhab.cfg (I've inserted a garbage value below):

# the AppKey, AppSecret combination (optional, defaults to official Dropbox-App
# Key-Secret-Combination)
#dropbox:appkey=
#dropbox:appsecret=
dropbox:personalAccessToken=dbkalfdog;a;gajga;hahjna;ajh;haj;hahj;

I'd appreciate someone trying this out to see if it works outside my test environment...

Rick-Jongbloed commented 7 years ago

I haven't been able to run the Dropbox IO bundle with your test jar. I'm using Openhab 1. I've taken the following steps:

  1. Created app in Dropbox
  2. Generated the Generated Access Token
  3. Configured openhab.cfg"
# the AppKey, AppSecret combination (optional, defaults to official Dropbox-App
# Key-Secret-Combination)
#dropbox:appkey=
#dropbox:appsecret=
dropbox:personalAccessToken=GZPW77lghj4AAAAAAAAU_very_long_token_jXdgY4lvRjf_UTKNxz8Y3djzL
  1. It seems the jar is still linking to the default app, as the log displays:

2016-12-14 21:53:33.185 [DEBUG] [.i.d.internal.DropboxActivator] - Dropbox IO Bundle has been started. 2016-12-14 21:53:33.257 [DEBUG] [d.internal.DropboxSynchronizer] - contentdir: . 2016-12-14 21:53:33.261 [DEBUG] [d.internal.DropboxSynchronizer] - bundle is properly configured: activating synchronizer 2016-12-14 21:53:33.275 [DEBUG] [d.internal.DropboxSynchronizer] - authenticated: scheduling jobs 2016-12-14 21:53:33.276 [DEBUG] [d.internal.DropboxSynchronizer] - scheduling BIDIRECTIONAL download interval: 0 0/5 ?, upload interval: 0 0 2 ? 2016-12-14 21:53:33.324 [DEBUG] [d.internal.DropboxSynchronizer] - Scheduled synchronization job (direction=Download) with cron expression '0 0/5 ?' 2016-12-14 21:53:33.335 [DEBUG] [d.internal.DropboxSynchronizer] - Scheduled synchronization job (direction=Upload) with cron expression '0 0 2 ?' 2016-12-14 21:55:00.017 [DEBUG] [d.internal.DropboxSynchronizer] - creating new DbxClient with config 2016-12-14 21:55:00.049 [DEBUG] [d.internal.DropboxSynchronizer] - Started synchronization from Dropbox to local ... 2016-12-14 21:55:01.033 [WARN ] [d.internal.DropboxSynchronizer] - Synchronizing data with Dropbox throws an exception: unexpected HTTP status code: 403: {"api_error": true, "user_error": "This app is currently disabled.", "error": "This app is currently disabled."}



Am i missing something, or is there something else i can try?
9037568 commented 7 years ago

As far as I can see that should work. Two thoughts: 1 - Check that you removed the old jar. 2 - Make sure you set the "Allow implicit grant" option in your new dropbox app to "Allow"...

Here's my log:

03:08:11.892 [DEBUG] [.i.d.internal.DropboxActivator:34   ] - Dropbox IO Bundle has been started.
03:08:11.908 [DEBUG] [d.internal.DropboxSynchronizer:648  ] - contentdir: .
03:08:11.908 [DEBUG] [d.internal.DropboxSynchronizer:684  ] - bundle is properly configured: activating synchronizer
03:08:11.923 [DEBUG] [d.internal.DropboxSynchronizer:697  ] - authenticated: scheduling jobs
03:08:11.923 [DEBUG] [d.internal.DropboxSynchronizer:721  ] - scheduling BIDIRECTIONAL download interval: 0 0/1 * * * ?, upload interval: 10 0/1 * * * ?
03:08:11.923 [DEBUG] [d.internal.DropboxSynchronizer:748  ] - Scheduled synchronization job (direction=Download) with cron expression '0 0/1 * * * ?'
03:08:11.923 [DEBUG] [d.internal.DropboxSynchronizer:748  ] - Scheduled synchronization job (direction=Upload) with cron expression '10 0/1 * * * ?'
03:09:00.030 [DEBUG] [d.internal.DropboxSynchronizer:817  ] - creating new DbxClient with config
03:09:00.046 [DEBUG] [d.internal.DropboxSynchronizer:256  ] - Started synchronization from Dropbox to local ...
03:09:00.798 [DEBUG] [d.internal.DropboxSynchronizer:265  ] - There are no deltas to download from Dropbox ...
woopelderly commented 7 years ago

On my windows 10 machine, your code change is working. I did have to remove a 'deltacursor.dbx' file from my openhab directory to get ride of an error. This is the error I was getting before removing the file:

2016-12-16 21:30:00.598 [WARN ] [d.internal.DropboxSynchronizer] - Synchronizing data with Dropbox throws an exception: {"error": "Invalid \"cursor\" parameter: this cursor is for a different app."}

9037568 commented 7 years ago

Good information to have. Thanks, @woopelderly.