Import Gmail Contacts (Resolved)

36 views
Skip to first unread message

toxicafunk

unread,
May 10, 2009, 10:55:04 AM5/10/09
to Pinax Users
Hi,

I'm using Pinax 0.7b2 on Ubuntu 9.04 (python 2.6) and I've been
getting a NonAuthSubToken exception when importing contacts from Gmail
on a project based on the social_project. I have finally managed to
get it working by changing code on authsub.views.login and on
friends_app.importer.import_google so I'm wondering if anyone else is
having the same problem or if its a bug specific to my system.

Anyway, in case anyone's interested (the original code is commented
with '#'):

# on authsub.views.login:
# add token to session for now
# request.session['authsub_token'] = request.GET["token"]
single_use_token = gdata.auth.extract_auth_sub_token_from_url
(get_full_url(request))
request.session['authsub_token'] = single_use_token

# then on friends_app.importer.import_google :
#contacts_service.auth_token = authsub_token
contacts_service.UpgradeToSessionToken(authsub_token)

Cheers,

Skylar Saveland

unread,
May 29, 2009, 5:29:25 PM5/29/09
to Pinax Users
I also have the same error and a similar jaunty/0.7b2 scenario. When
I comment the two lines that you suggest I get no tracebacks or errors
but I never get the "import" button either. i have tried all
permutation of one or the other.

toxicafunk

unread,
May 30, 2009, 11:53:11 AM5/30/09
to Pinax Users
I just tried it and it works for me so let's retrace:

1. Copy the authsub app from [PINAX_HOME]/src/pinax/pinax/apps/authsub
to [YOUR_PROJECT_HOME]/apps/authsub
2. modify [YOUR_PROJECT_HOME]/apps/authsub/views 'login' method by
replacing:

request.session['authsub_token'] = request.GET["token"]

with the following two lines:

single_use_token = gdata.auth.extract_auth_sub_token_from_url
(get_full_url(request))
request.session['authsub_token'] = single_use_token

3. copy friends_app from [PROJECTS_HOME]/social_project/apps/
friends_app to [YOUR_PROJECT_HOME]/apps/friends_app
4. copy importer.py from [PINAX_HOME]/lib/python2.6/site-packages/
friends to [YOUR_PROJECT_HOME]/apps/friends_app
5. on the import_google method replace the line:

contacts_service.auth_token = authsub_token

with:

contacts_service.UpgradeToSessionToken(authsub_token)

6. Done.

Of course, you can change the files on their original source without
copying them to your own project but then you risk to loose the
changes on an Pinax update or whatever.

Hope this helps,


On May 29, 11:29 pm, Skylar Saveland <skylar.savel...@gmail.com>
wrote:

Skylar Saveland

unread,
May 31, 2009, 4:24:06 AM5/31/09
to Pinax Users
> Of course, you can change the files on their original source without
> copying them to your own project but then you risk to loose the
> changes on an Pinax update or whatever.
>
> Hope this helps,

This is definitely helpful. I am still getting my bearing with the
layout of pinax and how the workflow is supposed to work. I was
indeed modifying the files in place. I would actually like to know
how I can onload most if not all of everything to my project_dir so
that I can just make changes and complete overhauls there but continue
to upgrade pinax without worry of it interfering with my existing
hacks. Unfortunately,

(pinax-env)skylar@ABC255:~/pinax$ pinax-admin clone_project
social_project mycogia
Copying your project to its new location
Updating settings.py for your new project
Renaming and updating your deployment files
Finished cloning your project, now you may enjoy Pinax!


(pinax-env)skylar@ABC255:~/pinax$ cp -r pinax-env/src/pinax/pinax/apps/
authsub mycogia/apps/authsub
(pinax-env)skylar@ABC255:~/pinax$ ls mycogia/apps/authsub/
__init__.py models.py urls.py views.py
(pinax-env)skylar@ABC255:~/pinax$ vim mycogia/apps/authsub/views.py


(pinax-env)skylar@ABC255:~/pinax$ cp -r pinax-env/src/pinax/pinax/
projects/social_project/apps/friends_app/ mycogia/apps/
(pinax-env)skylar@ABC255:~/pinax$ ls mycogia/apps/friends_app/
context_processors.py forms.py __init__.py models.py urls.py
views.py
(pinax-env)skylar@ABC255:~/pinax$ cp pinax-env/lib/python2.6/site-
packages/friends/importer.py mycogia/apps/friends_app/
(pinax-env)skylar@ABC255:~/pinax$ ls mycogia/apps/friends_app/
context_processors.py forms.py importer.py __init__.py models.py
urls.py views.py

(pinax-env)skylar@ABC255:~/pinax$ vim mycogia/apps/friends_app/
importer.py
(pinax-env)skylar@ABC255:~/pinax$ cd mycogia/
(pinax-env)skylar@ABC255:~/pinax/mycogia$ ./manage.py syncdb
/home/skylar/pinax/pinax-env/lib/python2.6/site-packages/friends/
models.py:3: DeprecationWarning: the sha module is deprecated; use the
hashlib module instead
import sha
Creating table auth_permission
...
...
Installing index for admin.LogEntry model
Installing index for django_openid.UserOpenidAssociation model
Installing json fixture 'initial_data' from '/home/skylar/pinax/pinax-
env/lib/python2.6/site-packages/oembed/fixtures'.
Installing json fixture 'initial_data' from '/home/skylar/pinax/
mycogia/apps/photos/fixtures'.
Installed 18 object(s) from 2 fixture(s)
(pinax-env)skylar@ABC255:~/pinax/mycogia$ ./manage.py runserver
/home/skylar/pinax/pinax-env/lib/python2.6/site-packages/friends/
models.py:3: DeprecationWarning: the sha module is deprecated; use the
hashlib module instead
import sha
/home/skylar/pinax/pinax-env/lib/python2.6/site-packages/friends/
models.py:3: DeprecationWarning: the sha module is deprecated; use the
hashlib module instead
import sha
Validating models...
0 errors found

Django version 1.0.2 final, using settings 'mycogia.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
/home/skylar/pinax/pinax-env/lib/python2.6/site-packages/
ybrowserauth.py:16: DeprecationWarning: the md5 module is deprecated;
use hashlib instead
import md5
[31/May/2009 04:16:22] "GET / HTTP/1.1" 200 4238
[31/May/2009 04:16:22] "GET /site_media/base.css HTTP/1.1" 304 0
[31/May/2009 04:16:22] "GET /site_media/pinax/css/tabs.css HTTP/1.1"
304 0
...
...
[31/May/2009 04:16:41] "GET /site_media/pinax/images/heading.png HTTP/
1.1" 304 0
[31/May/2009 04:16:41] "GET /site_media/pinax/js/uni-form.jquery.js
HTTP/1.1" 304 0
[31/May/2009 04:16:41] "GET /site_media/base.js HTTP/1.1" 304 0
/home/skylar/pinax/pinax-env/lib/python2.6/site-packages/djangodblog/
middleware.py:26: DeprecationWarning: BaseException.message has been
deprecated as of Python 2.6
message = getattr(exception, 'message', ''),
[31/May/2009 04:16:43] "POST /invitations/contacts/ HTTP/1.1" 500
94245

``NonAuthSubToken at /invitations/contacts/``

The edited methods can be found here:
http://dpaste.com/49644/

Please tell me how my actions have differed from what you have done
that works.

Skylar Saveland

unread,
May 31, 2009, 6:35:06 AM5/31/09
to Pinax Users
> 4. copy importer.py from [PINAX_HOME]/lib/python2.6/site-packages/
> friends to [YOUR_PROJECT_HOME]/apps/friends_app

Okay, I got it. It looks like the friends module and the friends_app
module are distinct so following these directions verbatim did not
work. But if I move the friends module from site-packages into my
project/apps/friends then make the modification it works. I don't
think that importer is part of friends_app though. A bit confusing
but thanks.

Also, I think:
> 5. on the import_google method replace the TWO lines:
>
> contacts_service.auth_token = authsub_token
> contacts_service.UpgradeToSessionToken()
>
> with:
>
> contacts_service.UpgradeToSessionToken(authsub_token)

Very helpful though... when is the ETA for patches like this to the
devel version? Also, after all of that I'm a little disappointed to
see that I just have a text list of my contacts but I guess I could
make them links to an invitation form...

Eric Rodriguez

unread,
Jun 1, 2009, 3:54:19 AM6/1/09
to pinax...@googlegroups.com
On Sun, May 31, 2009 at 12:35 PM, Skylar Saveland <skylar....@gmail.com> wrote:

> 4. copy importer.py from [PINAX_HOME]/lib/python2.6/site-packages/
> friends to [YOUR_PROJECT_HOME]/apps/friends_app

Okay, I got it.  It looks like the friends module and the friends_app
module are distinct so following these directions verbatim did not
work.  But if I move the friends module from site-packages into my
project/apps/friends then make the modification it works.  I don't
think that importer is part of friends_app though.  A bit confusing
but thanks.

Well, the thing is like this: the 'friends' functionality is provided by the 'friends' application on your site-packages, however you may notice the views of that app is empty. This is because yuo have to provide your
own views suited for your application, for instance, the social-project implements its own views on the friends-app. Instead of moving the whole friends module, you may instead just copy the importer.py and then change your import from:

from friends.importer import import_yahoo, import_google

to:

from friends-app import import_google

but this is up to you. I forgot to tell you about this last bit before.

Also, I think:
> 5. on the import_google method replace the TWO lines:
>
> contacts_service.auth_token = authsub_token
> contacts_service.UpgradeToSessionToken()
>
> with:
>
> contacts_service.UpgradeToSessionToken(authsub_token)

Very helpful though... when is the ETA for patches like this to the
devel version?  Also, after all of that I'm a little disappointed to
see that I just have a text list of my contacts but I guess I could
make them links to an invitation form...

I should clarify that I'm not a pinax developer, i'm just like you trying to build a project on pinax. My understanding is that you provide your own functionality with the imported contacts.

Cheers and good luck,


 



Skylar Saveland

unread,
Jun 1, 2009, 9:08:51 AM6/1/09
to pinax...@googlegroups.com

I should clarify that I'm not a pinax developer, i'm just like you trying to build a project on pinax. My understanding is that you provide your own functionality with the imported contacts.

Cheers and good luck,

Awesome, well, thanks for all the help; I'm starting to get a better handle on it.  I hope to contribute but obviously I have a little farther to go.  Just trying to add fuel to the fire, hopefully not smothering it.
Reply all
Reply to author
Forward
0 new messages