After migration: Dropbox Encryption key is invalid

After migration to new server, when I try to configure the Dropbox settings, after I enter the App access key and app secret key and click on Allow Dropbox Access I get the error:

Encryption key is invalid, Please check site_config.json

Hi @Samuel_Gervais

Try to change password again at Dropbox.

I tried to change app access key, app secret key, change email, save, reload, clear cache, but nothing works. still getting same error

and if I set the app access key and secret key in the site_config.json I get this error instead: Something went wrong while generating dropbox access token. Please check error log for more details.

Latest error in the error log is
> Traceback (most recent call last):

File “/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/dropbox_settings/dropbox_settings.py”, line 229, in get_redirect_url
response = make_post_request(url, data={“site”: get_url()})
File “/home/frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py”, line 50, in make_post_request
raise exc
MissingSchema: Invalid URL ‘None/api/method/dropbox_erpnext_broker.www.setup_dropbox.get_authotize_url’: No schema supplied. Perhaps you meant http://None/api/method/dropbox_erpnext_broker.www.setup_dropbox.get_authotize_url?

and the second error

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/integrations/utils.py”, line 41, in make_post_request
frappe.flags.integration_request = s.post(url, data=data, auth=auth, headers=headers)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/requests/sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/requests/sessions.py”, line 519, in request
prep = self.prepare_request(req)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/requests/sessions.py”, line 462, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/requests/models.py”, line 313, in prepare
self.prepare_url(url, params)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/requests/models.py”, line 387, in prepare_url
raise MissingSchema(error)
MissingSchema: Invalid URL ‘None/api/method/dropbox_erpnext_broker.www.setup_dropbox.get_authotize_url’: No schema supplied. Perhaps you meant http://None/api/method/dropbox_erpnext_broker.www.setup_dropbox.get_authotize_url?

https://erpnext.org/docs/user/manual/en/setting-up/integrations/dropbox-backup

Seems you need to recheck:
Step 4: Insert your custom domain Redirect URI

There is a problem visible in the error message in the URI.
“http://None/api/method/dropbox_erpnext_broker.**www.**setup_dropbox.get_authotize_url?”

That encryption key error occurs after you do a restore of database to a new server.
If thats the case and you still have access to your previous server, go to that file site_config.json of your old server, you will see the encryption keys there. Copy them and paste them in the site_config.json of your new server

I did this step but yes I also noticed that. I dont know where the “none” is comming from. Everything is configured as it says in the manual

I can’t because I was on the hosted ERPNext

1 Like

Thats unfortunate. have you tried requesting your encryption keys from them?

I’ll try.
What I dont understand is that everything else work. If it really was a encryption key error, I wouldnt be able to add new user and do stuff like that…

1 Like

without the original encryption keys some functions might not work, backup being one of them.
what about email function, is it working? there isn’t really a list of what will work and what won’t. you just have to test the whole system see.

yes email work too. If I understand well, if it really was an encryption key problem, emails wouldnt work…

Hi @Samuel_Gervais

I think you need to check again OAuth 2 - Redirect URIs at dropbox and App key and App secret
And click again “Allow dropbox Access”

Make sure all are correct?

Selection_045

1 Like

Here’s another solution that works:

  1. Generate access token here:

  1. Run following in bench console:
doc = frappe.get_doc('Dropbox Settings', 'Dropbox Settings')
doc.dropbox_access_token = "[your generated token here]"
doc.save()
frappe.db.commit()
4 Likes

Thanks for your help.
Yes i’m sure the app access key is good and secret key too.
I did try to change the dropbox access token (this field is also accessible if you customize the doctype to unhide it).
Also tried with the bench console

The error I get after putting new access token is the same error: Encryption key is invalid, Please check site_config.json

I even created a new dropbox app and tried everything again and same error.

Hi

Try to input wrong app secret key => save=> allow Dropbox access => input correct app secret key => save => allow Dropbox access . My point want to update again app secret key again.

Thanks for your ideas. Still getting same error: Encryption key is invalid, Please check site_config.json

As a final resort, deleting Dropbox Settings and starting over should work.
(Yes, you can delete single DocTypes too.)

I have noticed that all issues crop up because the site name may have changed upon migration to another server. I guess the encryption key in site_config.json must be backed up too?

1 Like

Wow it worked! I deleted the dropbox settings (menu, delete. Then clean cache just in case) and enter settings again and it worked first time!

Regarding, the encryption key,yes I think it should be backup too.

2 Likes

This worked for me. Had to run these commands in the console as the “allow dropbox access” button gives error 400. Other posts have said to customize the dropbox settings form so you can enter an Access token generated from dropbox, but the menu–>customize button has been removed in newer versions of erpnext (leaving no way to enter the access token).

So from a command line, entering “bench console”, then the above solution solved my dropbox setup issues.

Thank you