I am an administrator of a Google Apps domain and am trying to write a program that will access the contacts of users on the domain (note that I'm not trying to get at the shared contacts, but the individual contacts for each user, so the shared contacts API won't help).
Initially I was using the "recommended" approach of three-legged auth (show a Web page, the user approves, use that token). That worked great, except if I tried any user other than myself I'd get a 403 forbidden error. So then I read that in this case I wanted two-legged auth, although it's deprecated.
Well, I've come up with this code but now I'm getting a 401/unauthorized credential. I'm not sure if the problem lies in my code or somewhere else (the way I registered the application or something) but I'm having a really hard time finding helpful documentation.
public static Feed<Contact> MakeRequest(string userId, int numberToRetrieve = 9999)
{
var settings = new RequestSettings(Properties.Settings.Default.ApplicationName,
Properties.Settings.Default.ApiKey, Properties.Settings.Default.ConsumerSecret,
Properties.Settings.Default.GoogleUserName, Properties.Settings.Default.Domain);
var cRequest = new ContactsRequest(settings);
var query = new ContactsQuery(ContactsQuery.CreateContactsUri(userId));
query.NumberToRetrieve = numberToRetrieve;
return cRequest.Get(query);
}