Closed joakimolsson closed 7 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?
@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!
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"}
@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
.
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?
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?
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.
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?
@teichsta Any news on this issue. I am also getting the warning.
Thanks, OvO
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?
I have a solution which allows this to work after creating a new app by using the generated access token.
I'll post details later...
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...
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:
# 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
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?
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 ...
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."}
Good information to have. Thanks, @woopelderly.
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:
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