Hi Sabya,

I think you need to Set the AuthSub Token to the ContactsService like
this:

  authsub_token = parameters['token'] # URL Parameter
  gd_client = gdata.contacts.service.ContactsService()
  gd_client.SetAuthSubToken(authsub_token)
  gd_client.UpgradeToSessionToken()
  feed = gd_client.GetContactsFeed()

I hope it helps.

--Julian

On Apr 7, 6:10 pm, sabya <[email protected]> wrote:
> I am trying to download contacts from a domain using the Contact API's
> Python Client Library.  I am able to get the AuthSubToken, which I
> then upgrade to a Session Token. However, an "Authorization required"
> error is returned when I execute the GetContactsFeed function.  My
> code looks something like this:
>
> next='[URL of page to return to]'
> scope='http://www.google.com/m8/feeds/'
> hd='[Domain name]'
> secure=False
> session=True
> client = gdata.service.GDataService()
> authSubLogin=client.GenerateAuthSubURL(next, scope, secure, session,
> hd)
>
> [At this point, I authenticate myself on the domain, after which I am
> returned to the page specified in the "next" parameter. I then extract
> the AuthSubToken from the URL]
>
> client = gdata.contacts.service.ContactsService()
> asToken = gdata.auth.AuthSubToken()
> asToken.set_token_string('[AuthSubToken returned in URL]')
> print client.upgrade_to_session_token(asToken)
> [The SessionToken gets printed here]
>
> feed = client.GetContactsFeed()
>
> After the last step I receive the following error:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.4/site-packages/gdata/contacts/service.py",
> line 95, in GetContactsFeed
>     return self.Get(uri,
> converter=gdata.contacts.ContactsFeedFromString)
>   File "/usr/lib/python2.4/site-packages/gdata/service.py", line 1022,
> in Get
>     raise RequestError, {'status': server_response.status,
> gdata.service.RequestError: {'status': 401, 'body': '<HTML>\n<HEAD>
> \n<TITLE>Authorization required</TITLE>\n</HEAD>\n<BODY
> BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Authorization required</H1>
> \n<H2>Error 401</H2>\n</BODY>\n</HTML>\n', 'reason': 'Authorization
> required'}
>
> What am I missing?
>
> Thanks in advance
> Sabya
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to