« Liar’s Paradox | Main | e2dot0 culture »
Monday
12Oct2009

Renaming a GAPE user account using cURL

This is a four step process:
  1. First obtain a Authentication Token:

    # curl https://www.google.com/accounts/ClientLogin -d Email=user@domain.tld –d Passwd=password –d accountType=HOSTED_OR_GOOGLE  -d source=cURL-Example -d service=wise

    This will return something that looks as follows:
    
    SID=DQAAAHYBADCv2pSv7nflacDNwz3zEDUGtrSvNVDcpkSfddi77b3U5sEaHmP8YLWhmA36F9rk85mL8J5dqo4apn0T1vKz0fPGI9Xtnuet6cuE2ZzYvrNIwbSC_HjTqF4zudNQnnlDuD2wqZT-g1qXI8KhGAQZV4NexHZoQPlabTsGuRZeIBxj1A 
    LSID=EUBBBIaBADCl-kNxvRVmcQghpt3cqSMfEooKR9flLOUZqwgP9OrZS83gse-KSdTNeXhxsET7FYenDhceP9lIPOmesH-t9qh-AWUHjjMdZEbUNeF9mWyzln6Z-FajaiG-cVFkqW0ZJ8ZbnCP30xXj6xFK6QxaAcqy_9Pej8jhEnxS9E61ftQGPg 
    Auth=EUBBIacAAADK-kNxvRVmcQghpt3cqSMfEooLNMflLNIQqwgP9OrZS83gs-KSdTNeXhxsET7FYePWmaD8Vsy1V4LSUGMUP48Je2TO8OcjBj6HgAtPhiZeX-gKDfagZDK44j4n-Tkb44nhOnp2_QPSnBj3Z2vYwOEDjjG3Q53aQVC2132JKOuGh
  2. Now use the AuthToken to retrieve the user account:
    # curl --silent --header "Authorization: GoogleLogin auth=AUTHKEY” "https://apps-apis.google.com/a/feeds/domain.tld/user/2.0/oldUserName" | tidy -xml -indent -quiet -wrap 300 > rename.xml
    This will generate a file called rename.xml containing the user account definition. The content of the rename.xml should look as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:apps="http://schemas.google.com/apps/2006"
     xmlns:gd="http://schemas.google.com/g/2005">
     <atom:id>https://apps-apis.google.com/a/feeds/example.com/user/2.0/OldUserName</atom:id>
     <atom:updated>1970-01-01T00:00:00.000Z</atom:updated>
     <atom:category scheme="http://schemas.google.com/g/2005#kind"
     term="http://schemas.google.com/apps/2006#user"/>
     <atom:title type="text">OldUserName</atom:title>
     <atom:link rel="self" type="application/atom+xml" 
     href="https://apps-apis.google.com/a/feeds/example.com/user/2.0/OldUserName"/>
     <atom:link rel="edit" type="application/atom+xml" 
     href="https://apps-apis.google.com/a/feeds/example.com/user/2.0/OldUserName"/>
     <apps:login userName="NewUserName" suspended="false" admin="false" changePasswordAtNextLogin="false" agreedToTerms="true"/>
     <apps:name familyName="Jones" givenName="Susan"/>
     <gd:feedLink rel="http://schemas.google.com/apps/2006#user.nicknames" 
     href="https://apps-apis.google.com/a/feeds/example.com/nickname/2.0?username=Susy-1321"/>
     <gd:feedLink rel="http://schemas.google.com/apps/2006#user.groups" 
     href="https://apps-apis.google.com/a/feeds//group/2.0/?recipient=us-sales@example.com"/>
    </atom:entry>
  3. Edit rename.xml and replace NewUserName with the new username for the user. You can also change the familyName, givenName or any other attribute in the <apps:login/> element.
  4. Use the following command to update the UserName on the GAPE server:
    # curl --silent --request PUT --data "@rename.xml" --header "Content-Type: application/atom+xml" --header "Authorization: GoogleLogin auth=AUTHKEY" "https://apps-apis.google.com/a/feeds/domain.tld/user/2.0/oldUserName"

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>