Retrieving users from an account with email domain

121 views
Skip to first unread message

Anthony Smith

unread,
Jul 1, 2011, 5:02:50 AM7/1/11
to google-app...@googlegroups.com
Hi,

Using the .Net GData API, how do I retrieve a list of users for an account who have different domain names and email addresses within a Google Apps for Business account ?

So for example - the account might have b...@domain1.com and su...@domain1.com, but also ha...@domain2.com - how do I retrieve Harry as well as Bob and Susan ?

Thanks.

Claudio Cherubino

unread,
Jul 1, 2011, 5:06:21 AM7/1/11
to google-app...@googlegroups.com
Hi Anthony,

The .NET library implements the methods exposed by the multidomain Provisioning API, such as retrieving users in a multidomain environment:


Claudio

--
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/-/Vw9VN7khRC8J.
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.

Anthony

unread,
Jul 16, 2011, 1:31:23 AM7/16/11
to google-app...@googlegroups.com
Thanks Claudio,

I'm not sure how to call RetrieveAllDomainUsers using 2 Legged OAuth (I'm a Google Apps Marketplace developer). Code posted below does not work, so hopefully you can point me in the right direction to get a read only list of all users in a domain, no matter what subdomain they belong to.

' create an OAuth factory to use
Dim requestFactory As New GOAuthRequestFactory("CS", "MyApp")
requestFactory.ConsumerKey = System.Configuration.ConfigurationManager.AppSettings("GoogleAppsConsumerKey")
requestFactory.ConsumerSecret = System.Configuration.ConfigurationManager.AppSettings("GoogleAppsConsumerSecret")
Dim newService As New MultiDomainManagementService(UserData.GOOGLE_APPS_DOMAIN, "MyApp")
newService.RequestFactory = requestFactory
Dim newFeed As AppsExtendedFeed = newService.RetrieveAllDomainUsers(UserData.GOOGLE_APPS_DOMAIN)
For Each entry As AppsExtendedEntry In newFeed.Entries
'Do Stuff
Next

Claudio Cherubino

unread,
Jul 17, 2011, 4:57:55 PM7/17/11
to google-app...@googlegroups.com
Hi Anthony,

What exactly is the problem with that code? You get an error or it returns incorrect results?

Claudio

--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.

Anthony Smith

unread,
Jul 18, 2011, 1:47:08 AM7/18/11
to google-app...@googlegroups.com
We get a 401 Unauthorized error, even when the permissions have been granted within the Google Apps control panel, so what I'm asking is how to structure the call so the 2 legged OAuth works with the MultiDomainManagementService.

Thanks

Claudio Cherubino

unread,
Jul 18, 2011, 2:41:32 AM7/18/11
to google-app...@googlegroups.com
Hi Anthony,

The Multidomain Provisioning API doesn't support 2-legged OAuth, but only 3-legged OAuth, as per the documentation:


Claudio

Anthony Smith

unread,
Jul 18, 2011, 3:00:25 AM7/18/11
to google-app...@googlegroups.com
Hi Claudio,

Thanks so much for the clarification and the prompt response. Do you have a sample anywhere of how to do 3 legged Oauth in either C# or VB.Net ? I was only able to find the link below which has Java, Python and PHP only for 3 legged.


Thanks.

Claudio Cherubino

unread,
Jul 18, 2011, 12:34:21 PM7/18/11
to google-app...@googlegroups.com
Hi Anthony,

We are working to update our library to include a complete .NET 3LO sample, in the meanwhile please use the following Spreadsheet API code as reference.
Please note that it doesn't show how to retrieve the token key and secret, but only how to use them once you have them:


GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("wise", APPLICATION_NAME);
requestFactory.ConsumerKey = "anonymous";
requestFactory.ConsumerSecret = "anonymous";
requestFactory.Token = TOKEN_KEY;
requestFactory.TokenSecret = TOKEN_SECRET;
requestFactory.UseSSL = true;

SpreadsheetsService myService = new SpreadsheetsService(APPLICATION_NAME);
myService.RequestFactory = requestFactory;

SpreadsheetQuery query = new SpreadsheetQuery();
SpreadsheetFeed feed = myService.Query(query);
...


Claudio
Reply all
Reply to author
Forward
0 new messages