Dropbox Error : to many values to unpack

109 views
Skip to first unread message

Hassan Alnatour

unread,
Oct 22, 2012, 9:11:13 AM10/22/12
to web...@googlegroups.com
Dear ALL , 
i am trying to work with dropbox API i addedthe file dropbox.key in app/private and added the keys in it , i added the dropbox module and i am getting this error , any help ?

regards,

Traceback (most recent call last):
File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
File "C:/web2py/applications/dropbox/models/db.py", line 67, in <module>
use_janrain(auth,filename='private/dropbox.key')
File "C:\web2py\gluon\contrib\login_methods\rpx_account.py", line 121, in use_janrain
domain,key = open(path,'r').read().strip().split(':')
ValueError: too many values to unpack

Massimo Di Pierro

unread,
Oct 22, 2012, 12:14:10 PM10/22/12
to web...@googlegroups.com
You cannot use janrain with dropbox. They are different APIs and use different keys. Look into 

gluon/contrib/login_methods/dropbox_account.py

for examples

hasan alnator

unread,
Oct 22, 2012, 12:39:15 PM10/22/12
to web...@googlegroups.com
Dear Massimo , 

i got this from the book :

from gluon.contrib.login_methods.dropbox_account import use_dropbox
use_janrain(auth,filename='private/dropbox.key')
mydropbox = auth.settings.login_form

http://web2py.com/books/default/chapter/29/14?search=dropbox#Dropbox-API

Best Regards,


--
 
 
 

Massimo Di Pierro

unread,
Oct 22, 2012, 5:23:32 PM10/22/12
to web...@googlegroups.com
Typo in the book:

from gluon.contrib.login_methods.dropbox_account import use_dropbox
use_dropbox(auth,filename='private/dropbox.key')
mydropbox = auth.settings.login_form

hasan alnator

unread,
Oct 23, 2012, 2:31:45 AM10/23/12
to web...@googlegroups.com
Dear Massimo , 

i changed it , but now i got this : 

Traceback (most recent call last):
File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/dropbox/controllers/default.py", line 82, in <module>
File "C:\web2py\gluon\globals.py", line 187, in <lambda>
self._caller = lambda f: f()
File "C:/web2py/applications/dropbox/controllers/default.py", line 44, in user
return dict(form=auth())
File "C:\web2py\gluon\tools.py", line 1205, in __call__
return getattr(self,args[0])()
File "C:\web2py\gluon\tools.py", line 2016, in login
cas_user = cas.get_user()
File "C:\web2py\gluon\contrib\login_methods\dropbox_account.py", line 62, in get_user
access_token = self.sess.obtain_access_token(self.sess.token)
File "applications\dropbox\modules\dropbox\session.py", line 205, in obtain_access_token
response = self.rest_client.POST(url, headers=headers, params=params, raw_response=True)
File "applications\dropbox\modules\dropbox\rest.py", line 260, in POST
return cls.IMPL.POST(*n, **kw)
File "applications\dropbox\modules\dropbox\rest.py", line 207, in POST
post_params=params, headers=headers, raw_response=raw_response)
File "applications\dropbox\modules\dropbox\rest.py", line 183, in request
raise ErrorResponse(r)
ErrorResponse: [401] u'Token is disabled or invalid'

Regards,

--
 
 
 

Massimo Di Pierro

unread,
Oct 23, 2012, 10:25:05 AM10/23/12
to web...@googlegroups.com
Do you have 2.1.1 or later? There was a bug in this in earlier version.

hasan alnator

unread,
Oct 23, 2012, 10:26:31 AM10/23/12
to web...@googlegroups.com
i am trying this in 2.1.1

regards,

--
 
 
 

peter

unread,
Oct 29, 2012, 11:01:26 AM10/29/12
to web...@googlegroups.com
I tried the example in the book in 2.1.1

It logs in okay, but when I try


    stream = open('afile.txt','rb')
    mydropbox.put('destfile.txt',stream)

I get a ticket

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Traceback (most recent call last
):
File "C:\Users\Peter\web2pyp1\gluon\restricted.py", line 212, in restricted
exec ccode in environment
File "C:/Users/Peter/web2pyp1/applications/new_spin2/controllers/default.py", line 658, in <module>
File "C:\Users\Peter\web2pyp1\gluon\globals.py", line 188, in <lambda>
self._caller = lambda f: f
()
File "C:/Users/Peter/web2pyp1/applications/new_spin2/controllers/default.py", line 654, in test_dropbox1
mydropbox.put('destfile.txt',stream)
File "C:\Users\Peter\web2pyp1\gluon\contrib\login_methods\dropbox_account.py", line 104, in put
return json.loads(self.client.put_file(filename, file))['bytes']
AttributeError: 'DropboxAccount' object has no attribute 'client'

 
Peter

Massimo Di Pierro

unread,
Oct 29, 2012, 11:23:00 PM10/29/12
to web...@googlegroups.com
I think I know what the problem is. I made a change in trunk. Can you check if it solves it?

peter

unread,
Oct 30, 2012, 8:54:45 AM10/30/12
to web...@googlegroups.com
Problem solved. Thanks
A minor point in the book. When it says

Create a file called "yourapp/private/dropbox.key" and in it write

<APP_KEY>:<APP_SECERT>:app_folder

It should maybe be made clear that app_folder should be literally 'app_folder'. I agree the lack of brackets suggests this, but I am sure that I am not the only one who would try and put the relevant application folder (in dropbox) there.

Peter
Reply all
Reply to author
Forward
0 new messages