Hello there, I need some help
I am using code from a sample in the Google Data Python Library 
(groups_provisioning_quick_start_example.py)
adapted to add a bunch of members to a group from a Csv file

*** The scenario*
Basically I am using the following two Python functions from my computer: 
1) for OAuth and 2) for adding members
1) def CreateGroupsClient(self):
    """Creates a groups provisioning client using OAuth2.0 flow."""
    token = gdata.gauth.OAuth2Token(
        client_id=self.client_id, client_secret=self.client_secret,
        scope=SCOPE, user_agent=USER_AGENT)
    uri = token.generate_authorize_url()
    print 'Please visit this URL to authorize the application:'
    print uri
    # Get the verification code from the standard input.
    code = raw_input('What is the verification code? ').strip()
    token.get_access_token(code)
    self.groups_client = gdata.apps.groups.client.GroupsProvisioningClient(
        domain=self.domain, auth_token=token)

2) def _AddMemberToGroupFromCsv(self):
    """Add a members to a particular group from a Csv file."""
    group_id = self._GetValidGroupId()
    newMembers = csv.reader(open('members.csv', 'rb'), delimiter=',', 
quotechar='|')
    print str(datetime.datetime.now())
    for idx,row in enumerate(newMembers):
        print idx+1, row[0]
        member_id = row[0]
        self.groups_client.AddMemberToGroup(group_id, member_id)
        print str(datetime.datetime.now())

*** The problem:*
It's working fine (too slow, probably due to Google restrictions)
However around 1 hour of running and just about 160 new members added, It 
would stop with the following error:
gdata.client.Unauthorized: Unauthorized - Server responded with: 401
Token invalid - Invalid token: Stateless token expired

*** My question:*
- how should I handle the authentication to avoid this early expiration ?

thanks in advance, Fausto

-- 
You received this message because you are subscribed to the Google Groups 
"Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-apps-mgmt-apis/-/VHr5pPGLLzAJ.
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-apps-mgmt-apis?hl=en.

Reply via email to