Error fetching Groups with Python library

41 views
Skip to first unread message

Mike Edwards

unread,
May 4, 2011, 9:24:20 AM5/4/11
to Google Apps Domain Information and Management APIs
My apologies if this isn't the correct place for this post, but I am
working with the Python gdata library but have run into an error. I
am migrating my users to Google Apps and my ultimate goal is to create
about a hundred groups and don't want to do it by hand. In testing
out the use of the python library, I tried the following:

import gdata.apps.groups.service
client = gdata.apps.groups.service.GroupsService()
client.ClientLogin('us...@mydomain.com', 'password')
client.RetrieveAllGroups()

But that throws an Error 403 Invalid domain. (Obviously, I used my
admin user ID so the domain is indeed valid. I can post the whole
error if someone cares.)

Can anyone throw me a clue here? And if there's a better group or
forum for this question, I will be happy to take it there.

Thanks,
Mike

Claudio Cherubino

unread,
May 4, 2011, 9:34:05 AM5/4/11
to google-app...@googlegroups.com
Hi Mike,

What is the edition of your Google Apps domain?
Please note that the Provisioning API is available for read/write access in Google Apps for Business, Education and ISPs and available in all Google Apps versions for read-only access by Apps Marketplace applications:


Claudio


--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
To post to this group, send email to google-app...@googlegroups.com.
To unsubscribe from this group, send email to google-apps-mgmt...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.


Mike Edwards

unread,
May 4, 2011, 12:15:25 PM5/4/11
to Google Apps Domain Information and Management APIs
Apps for Business. I had a head-slap moment and realized I hadn't
enabled the provisioning API, but even with that switched on, I get
the same error.

I have successfully retrieved a list of documents with
GetDocumentListFeed, so I think Python and the gdata modules are
installed properly.

Thanks,
Mike

On May 4, 8:34 am, Claudio Cherubino <ccherub...@google.com> wrote:
> Hi Mike,
>
> What is the edition of your Google Apps domain?
> Please note that the Provisioning API is available for read/write access in
> Google Apps for Business, Education and ISPs and available in all Google
> Apps versions for read-only access by Apps Marketplace applications:
>
> http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_...
>
> Claudio
>
>
>
>
>
>
>
> On Wed, May 4, 2011 at 2:24 PM, Mike Edwards <mike.edwa...@ega.com> wrote:
> > My apologies if this isn't the correct place for this post, but I am
> > working with the Python gdata library but have run into an error.  I
> > am migrating my users to Google Apps and my ultimate goal is to create
> > about a hundred groups and don't want to do it by hand.  In testing
> > out the use of the python library, I tried the following:
>
> > import gdata.apps.groups.service
> > client = gdata.apps.groups.service.GroupsService()
> > client.ClientLogin('u...@mydomain.com', 'password')

Claudio Cherubino

unread,
May 4, 2011, 12:21:50 PM5/4/11
to google-app...@googlegroups.com
Can you please try performing the same request with cURL?


Also, the complete error can definitely help.
Thanks

Claudio

Mike Edwards

unread,
May 4, 2011, 2:27:27 PM5/4/11
to Google Apps Domain Information and Management APIs
Hmmm. I've used curl before, but not with Apps. I'm trying to follow
http://code.google.com/apis/gdata/articles/using_cURL.html but keep
getting an "Invalid Token" despite running the ClientLogin URL first,
and then the one with the Authorization header. (My Auth token from
the first step is much longer than the example and is different every
time I run it.)

curl https://apps-apis.google.com/accounts/ClientLogin --data-
urlencode Email=us...@mydomain.com --data-urlencode Passwd=secret -d
accountType=GOOGLE -d source=Google-cURL-test -d service=lh2
curl --silent --header "Authorization: GoogleLogin
Auth=very_long_string" "https://apps-apis.google.com/a/feeds/group/2.0/
mydomain.com"


Here's the error from the python test I ran:

Traceback (most recent call last):
File "groups.py", line 8, in <module>
client.RetrieveAllGroups()
File "/usr/lib/python2.6/site-packages/gdata/apps/groups/
service.py", line 164, in RetrieveAllGroups
return self._GetPropertiesList(uri)
File "/usr/lib/python2.6/site-packages/gdata/apps/service.py", line
510, in _GetPropertiesList
property_feed = self._GetPropertyFeed(uri)
File "/usr/lib/python2.6/site-packages/gdata/apps/service.py", line
507, in _GetPropertyFeed
raise gdata.apps.service.AppsForYourDomainException(e.args[0])
gdata.apps.service.AppsForYourDomainException: {'status': 403, 'body':
'<HTML>\n<HEAD>\n<TITLE>Invalid domain.</TITLE>\n</HEAD>\n<BODY
BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Invalid domain.</H1>\n<H2>Error
403</H2>\n</BODY>\n</HTML>\n', 'reason': 'Invalid domain.'}

Mike

On May 4, 11:21 am, Claudio Cherubino <ccherub...@google.com> wrote:
> Can you please try performing the same request with cURL?
>
> http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_...

Claudio Cherubino

unread,
May 4, 2011, 5:00:11 PM5/4/11
to google-app...@googlegroups.com
Mike,

The service parameter in your cURL request is wrong, if you want to retrieve an Auth token for the Provisioning API its value should be "apps", not "lh2".
Please trying using the following format:

curl https://www.google.com/accounts/ClientLogin --request POST -d Email=AD...@YOURDOMAIN.COM -d Passwd=YOURPASSWORD -d accountType=HOSTED -d service=apps

Thanks
Claudio

Mike Edwards

unread,
May 4, 2011, 6:20:27 PM5/4/11
to Google Apps Domain Information and Management APIs
OK, thanks for that info. Processing via curl worked, so that leads
me to believe it is not a problem on the Apps side, at least.

On May 4, 4:00 pm, Claudio Cherubino <ccherub...@google.com> wrote:
> Mike,
>
> The service parameter in your cURL request is wrong, if you want to retrieve
> an Auth token for the Provisioning API its value should be "apps", not
> "lh2".
> Please trying using the following format:
>
> curlhttps://www.google.com/accounts/ClientLogin--request POST -d Email=
> AD...@YOURDOMAIN.COM -d Passwd=YOURPASSWORD -d accountType=HOSTED -d
> service=apps
>
> Thanks
> Claudio
>
>
>
>
>
>
>
> On Wed, May 4, 2011 at 7:27 PM, Mike Edwards <mike.edwa...@ega.com> wrote:
> > Hmmm.  I've used curl before, but not with Apps.  I'm trying to follow
> >http://code.google.com/apis/gdata/articles/using_cURL.htmlbut keep
> > getting an "Invalid Token" despite running the ClientLogin URL first,
> > and then the one with the Authorization header. (My Auth token from
> > the first step is much longer than the example and is different every
> > time I run it.)
>
> > curlhttps://apps-apis.google.com/accounts/ClientLogin--data-
> > urlencode Email=u...@mydomain.com --data-urlencode Passwd=secret -d
> > accountType=GOOGLE -d source=Google-cURL-test -d service=lh2
> > curl --silent --header "Authorization: GoogleLogin
> > Auth=very_long_string" "https://apps-apis.google.com/a/feeds/group/2.0/
> > mydomain.com <https://apps-apis.google.com/a/feeds/group/2.0/mydomain.com>

Mike Edwards

unread,
May 9, 2011, 12:20:38 PM5/9/11
to Google Apps Domain Information and Management APIs
I'm still struggling this from the Python side. Can anyone help me
out with the authentication process? I used something similar to the
above to retrieve a list of docs, and it worked fine, but I can't
understand why this is failing.

On May 4, 5:20 pm, Mike Edwards <mike.edwa...@ega.com> wrote:
> OK, thanks for that info.  Processing via curl worked, so that leads
> me to believe it is not a problem on the Apps side, at least.
>
> On May 4, 4:00 pm, Claudio Cherubino <ccherub...@google.com> wrote:
>
>
>
>
>
>
>
> > Mike,
>
> > The service parameter in your cURL request is wrong, if you want to retrieve
> > an Auth token for the Provisioning API its value should be "apps", not
> > "lh2".
> > Please trying using the following format:
>
> > curlhttps://www.google.com/accounts/ClientLogin--requestPOST -d Email=

Claudio Cherubino

unread,
May 11, 2011, 2:56:54 AM5/11/11
to google-app...@googlegroups.com
Hi Mike,

This is a Python sample code that retrieves all groups for a Google Apps domain:


import gdata.apps.groups.service
service = gdata.apps.groups.service.GroupsService(email='AD...@DOMAIN.COM', domain='EXAMPLE.COM', password='MY_PASSWORD')
service.ProgrammaticLogin()
service.RetrieveAllGroups()


Please check the documentation for further issues with the Python client library for the Provisioning API:


Claudio

Mike Edwards

unread,
May 11, 2011, 4:10:41 PM5/11/11
to Google Apps Domain Information and Management APIs
Thank you for pointing that out.

Cheers!
Mike

On May 11, 1:56 am, Claudio Cherubino <ccherub...@google.com> wrote:
> Hi Mike,
>
> This is a Python sample code that retrieves all groups for a Google Apps
> domain:
>
> import gdata.apps.groups.service
> service = gdata.apps.groups.service.GroupsService(email='AD...@DOMAIN.COM',
> domain='EXAMPLE.COM', password='MY_PASSWORD')
> service.ProgrammaticLogin()
> service.RetrieveAllGroups()
>
> Please check the documentation for further issues with the Python client
> library for the Provisioning API:
>
> http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_...
>
> Claudio
>
>
>
>
>
>
>
> On Mon, May 9, 2011 at 9:20 AM, Mike Edwards <mike.edwa...@ega.com> wrote:
> > I'm still struggling this from the Python side.  Can anyone help me
> > out with the authentication process?  I used something similar to the
> > above to retrieve a list of docs, and it worked fine, but I can't
> > understand why this is failing.
>
> > On May 4, 5:20 pm, Mike Edwards <mike.edwa...@ega.com> wrote:
> > > OK, thanks for that info.  Processing via curl worked, so that leads
> > > me to believe it is not a problem on the Apps side, at least.
>
> > > On May 4, 4:00 pm, Claudio Cherubino <ccherub...@google.com> wrote:
>
> > > > Mike,
>
> > > > The service parameter in your cURL request is wrong, if you want to
> > retrieve
> > > > an Auth token for the Provisioning API its value should be "apps", not
> > > > "lh2".
> > > > Please trying using the following format:
>
> > > > curlhttps://www.google.com/accounts/ClientLogin--requestPOST-d Email=

BeloitProgrammer

unread,
Jun 28, 2011, 10:45:39 AM6/28/11
to google-app...@googlegroups.com
Saw this code while looking for an answer to a different question. Thought you might be able to help.

I try running this sample code but  get an error.

import gdata.apps.groups.service

if __name__=='__main__':
    service = gdata.apps.groups.service.GroupsService(email='nad...@beloit.edu', domain='beloit.edu', password='1bogart11')
    service.ProgrammaticLogin()
    service.RetrieveAllGroups()

[root@bcmail sbin]# python testGroup.py

Traceback (most recent call last):
  File "testGroup.py", line 2, in ?
    import gdata.apps.groups.service
ImportError: No module named groups.service


I feel like I am probably missing libraries. How do I get the right ones?


Thanks in advance

-DN

Claudio Cherubino

unread,
Jun 28, 2011, 10:50:29 AM6/28/11
to google-app...@googlegroups.com
This article should help you getting started with the Python library:


Claudio

--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
Reply all
Reply to author
Forward
0 new messages