{"id":4530,"date":"2010-07-28T09:15:00","date_gmt":"2010-07-28T09:15:00","guid":{"rendered":"https:\/\/www.sotec.eu\/?p=4530"},"modified":"2025-09-04T12:49:15","modified_gmt":"2025-09-04T12:49:15","slug":"using-the-google-apps-profile-api","status":"publish","type":"post","link":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/","title":{"rendered":"Using the Google Apps Profile API"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">As Google Apps reseller we develop applications to automate certain tasks in conjunction with Google Apps. For examples you can take a look at our&nbsp;<a href=\"http:\/\/www.google.com\/enterprise\/marketplace\/viewVendorListings?vendorId=1756\">Google Marketplace page<\/a>. One of our products there is the Sync Shared Contacts tool which synchonizes LDAP\/Active Directory entries to Domain Shared Contacts on the Google Servers. But contacts who have a user account for your Apps domain are not shown. Instead the user\u2019s profile is shown. Since profiles and contacts are two different things we needed to add the synchronization for profiles as well. This is possible since Google released the Profile API for Apps Premier, Education and Partner Edition.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since the Profile API is fairly new there are no profile classes for C# present yet. You can however use the Contacts API classes for profiles with a little bit of work. Here is how to do it:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To do anything with Google Apps API you have to get authenticated. The following example shows how to do this.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \"cp\" is required for profiles\nFeedService = new Service(\"cp\", \"COMPANY-PRODUCT-VERSION\");\n\/\/ if you don't set the ProtocolMajor to 3 nothing will work as expected\nFeedService.ProtocolMajor = 3;\n\/\/ Set your admin credentials\nFeedService.setUserCredentials(\"admin@yourdomain.com\", \"password\");\n\/\/ get an Auth token for the future\nstring AuthToken = FeedService.QueryClientLoginToken();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The next step would be to retrieve some profile information. Lets get all profiles for starters. Receive the AtomFeed and then parse it into a ContactsFeed. Then remove unnecessary xml nodes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>string uriString = \"https:\/\/www.google.com\/m8\/feeds\/profiles\/domain\/yourdomain.com\/full\";\n\/\/ Create a query\nFeedQuery query = new FeedQuery(uriString);\/\/ Query the service\nAtomFeed profFeed = FeedService.Query(query);\n\/\/ Write AtomFeed to MemoryStream\nStream memstream = new MemoryStream();\nprofFeed.SaveToXml(memstream);\nmemstream.Position = 0;\n\/\/ create new ContacsFeed\nContactsFeed ProfilesFeed = new ContactsFeed(new Uri(uriString), FeedService);\n\/\/ Parse the AtomFeed into the ContactsFeed\nProfilesFeed.Parse(memstream, AlternativeFormat.Atom);\n\/\/ Clean Up\nmemstream.Close();\n\/\/ We now have profiles as contacts. Remove unnecessary nodes from Feed\nforeach (ContactEntry ae in ProfilesFeed.Entries)\n{\nae.Categories.Remove(new AtomCategory(\"http:\/\/schemas.google.com\/contact\/2008#contact\"));\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We now have a lot of profiles to work on.<br>If you intend to set new email\/postal addresses or phone numbers you should not forget to set a relationship. If you don\u2019t you will get an error when your\u2019re attempting to update the profile. Have a look at the following example. It shows how to add a primary Email address to the first profile in our list of profiles.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ContactEntry profile = ProfilesFeed.Entries&#91;0];\nnewEmail = new EMail();\nnewEmail.Primary = true;\nnewEmail.Address = \"account@yourdomain.com\";\nnewEmail.Rel = EmailRel.work;\nprofile.Emails.Add(newEmail);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also add an postal address. You can use object attributes like Street, Postcode, etc. You should however also fill the FormattedAddress Attribute (and the relationship of course).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>StructuredPostalAddress pb = new StructuredPostalAddress();\npb.Primary = true;\npb.Rel = ContactsRelationships.IsWork;\npb.Street = \"Street 101\">\npb.Postcode = \"PO123\";\npb.City = \"City\";\npb.Country = \"US\";\n\/\/ You have to set the Formatted Address for Profiles!\npb.FormattedAddress = \"Street 101, PO123 City, State\";\nprofile.PostalAddresses.Add(pb);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now that the profile is modified you can upload the changes to the Google servers. Use the following code snippet to do so.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>profile.Update();<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Although not covered in this artice I\u2019d like to add that you can update multiple profiles at a time. The feature is called batch processing. Take a look at the&nbsp;<a href=\"http:\/\/code.google.com\/intl\/de-DE\/googleapps\/domain\/profiles\/developers_guide_protocol.html#Batch\">API Documentation<\/a>&nbsp;for more info.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Oh before I forget, these were the Google libraries that I used:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">using Google.GData.Client;<br>using Google.Contacts;<br>using Google.GData.Contacts;<br>using Google.GData.Extensions;<br>using Google.GData.GoogleBase;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This article is based on the Google Data API Version 1.6.0.0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As Google Apps reseller we develop applications to automate certain tasks in conjunction with Google Apps. For examples you can take a look at our\u00a0Google Marketplace page. One of our products there is the Sync Shared Contacts tool which synchonizes LDAP\/Active Directory entries to Domain Shared Contacts on the Google Servers. But contacts who have a user account for your Apps domain are not shown. Instead the user\u2019s profile is shown. Since profiles and contacts are two different things we needed to add the synchronization for profiles as well. This is possible since Google released the Profile API for Apps Premier, Education and Partner Edition.<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4530","post","type-post","status-publish","format-standard","hentry","category-nicht-kategorisiert"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the Google Apps Profile API - SOTEC<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the Google Apps Profile API - SOTEC\" \/>\n<meta property=\"og:description\" content=\"As Google Apps reseller we develop applications to automate certain tasks in conjunction with Google Apps. For examples you can take a look at our\u00a0Google Marketplace page. One of our products there is the Sync Shared Contacts tool which synchonizes LDAP\/Active Directory entries to Domain Shared Contacts on the Google Servers. But contacts who have a user account for your Apps domain are not shown. Instead the user\u2019s profile is shown. Since profiles and contacts are two different things we needed to add the synchronization for profiles as well. This is possible since Google released the Profile API for Apps Premier, Education and Partner Edition.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/\" \/>\n<meta property=\"og:site_name\" content=\"SOTEC\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-28T09:15:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-04T12:49:15+00:00\" \/>\n<meta name=\"author\" content=\"Anna Akinchyna\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anna Akinchyna\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/\"},\"author\":{\"name\":\"Anna Akinchyna\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#\\\/schema\\\/person\\\/07cb9b84a952982037f22f56d491df03\"},\"headline\":\"Using the Google Apps Profile API\",\"datePublished\":\"2010-07-28T09:15:00+00:00\",\"dateModified\":\"2025-09-04T12:49:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/\"},\"wordCount\":407,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#organization\"},\"articleSection\":[\"Nicht kategorisiert\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/\",\"url\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/\",\"name\":\"Using the Google Apps Profile API - SOTEC\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#website\"},\"datePublished\":\"2010-07-28T09:15:00+00:00\",\"dateModified\":\"2025-09-04T12:49:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/using-the-google-apps-profile-api\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using the Google Apps Profile API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/\",\"name\":\"SOTEC\",\"description\":\"Engineering for Digital Transformation\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#organization\",\"name\":\"SOTEC\",\"url\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.sotec.eu\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/logo-en-raster-1-scaled.png\",\"contentUrl\":\"https:\\\/\\\/www.sotec.eu\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/logo-en-raster-1-scaled.png\",\"width\":2560,\"height\":634,\"caption\":\"SOTEC\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/#\\\/schema\\\/person\\\/07cb9b84a952982037f22f56d491df03\",\"name\":\"Anna Akinchyna\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa135b4d99d22de7eb18b5a8aad37e4346b806b5e6ac52e75ab2706cf48ebe7d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa135b4d99d22de7eb18b5a8aad37e4346b806b5e6ac52e75ab2706cf48ebe7d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa135b4d99d22de7eb18b5a8aad37e4346b806b5e6ac52e75ab2706cf48ebe7d?s=96&d=mm&r=g\",\"caption\":\"Anna Akinchyna\"},\"url\":\"https:\\\/\\\/www.sotec.eu\\\/en\\\/author\\\/a-akinchynasotec-eu\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the Google Apps Profile API - SOTEC","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/","og_locale":"en_US","og_type":"article","og_title":"Using the Google Apps Profile API - SOTEC","og_description":"As Google Apps reseller we develop applications to automate certain tasks in conjunction with Google Apps. For examples you can take a look at our\u00a0Google Marketplace page. One of our products there is the Sync Shared Contacts tool which synchonizes LDAP\/Active Directory entries to Domain Shared Contacts on the Google Servers. But contacts who have a user account for your Apps domain are not shown. Instead the user\u2019s profile is shown. Since profiles and contacts are two different things we needed to add the synchronization for profiles as well. This is possible since Google released the Profile API for Apps Premier, Education and Partner Edition.","og_url":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/","og_site_name":"SOTEC","article_published_time":"2010-07-28T09:15:00+00:00","article_modified_time":"2025-09-04T12:49:15+00:00","author":"Anna Akinchyna","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Anna Akinchyna","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/#article","isPartOf":{"@id":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/"},"author":{"name":"Anna Akinchyna","@id":"https:\/\/www.sotec.eu\/en\/#\/schema\/person\/07cb9b84a952982037f22f56d491df03"},"headline":"Using the Google Apps Profile API","datePublished":"2010-07-28T09:15:00+00:00","dateModified":"2025-09-04T12:49:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/"},"wordCount":407,"commentCount":0,"publisher":{"@id":"https:\/\/www.sotec.eu\/en\/#organization"},"articleSection":["Nicht kategorisiert"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/","url":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/","name":"Using the Google Apps Profile API - SOTEC","isPartOf":{"@id":"https:\/\/www.sotec.eu\/en\/#website"},"datePublished":"2010-07-28T09:15:00+00:00","dateModified":"2025-09-04T12:49:15+00:00","breadcrumb":{"@id":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sotec.eu\/en\/using-the-google-apps-profile-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/www.sotec.eu\/en\/"},{"@type":"ListItem","position":2,"name":"Using the Google Apps Profile API"}]},{"@type":"WebSite","@id":"https:\/\/www.sotec.eu\/en\/#website","url":"https:\/\/www.sotec.eu\/en\/","name":"SOTEC","description":"Engineering for Digital Transformation","publisher":{"@id":"https:\/\/www.sotec.eu\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sotec.eu\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.sotec.eu\/en\/#organization","name":"SOTEC","url":"https:\/\/www.sotec.eu\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sotec.eu\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.sotec.eu\/wp-content\/uploads\/2024\/11\/logo-en-raster-1-scaled.png","contentUrl":"https:\/\/www.sotec.eu\/wp-content\/uploads\/2024\/11\/logo-en-raster-1-scaled.png","width":2560,"height":634,"caption":"SOTEC"},"image":{"@id":"https:\/\/www.sotec.eu\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.sotec.eu\/en\/#\/schema\/person\/07cb9b84a952982037f22f56d491df03","name":"Anna Akinchyna","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa135b4d99d22de7eb18b5a8aad37e4346b806b5e6ac52e75ab2706cf48ebe7d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa135b4d99d22de7eb18b5a8aad37e4346b806b5e6ac52e75ab2706cf48ebe7d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa135b4d99d22de7eb18b5a8aad37e4346b806b5e6ac52e75ab2706cf48ebe7d?s=96&d=mm&r=g","caption":"Anna Akinchyna"},"url":"https:\/\/www.sotec.eu\/en\/author\/a-akinchynasotec-eu\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/posts\/4530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/comments?post=4530"}],"version-history":[{"count":1,"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/posts\/4530\/revisions"}],"predecessor-version":[{"id":4531,"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/posts\/4530\/revisions\/4531"}],"wp:attachment":[{"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/media?parent=4530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/categories?post=4530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sotec.eu\/en\/wp-json\/wp\/v2\/tags?post=4530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}