Comment utiliser les Contacts Google API via l'authentification Oauth2

J'ai ce code ci-dessous pour obtenir les entrées de calendrier à l'aide de l'API google Agenda (https://developers.google.com/google-apps/calendar/) qui utilise OAuth2.
Il fonctionne bien.

private IList<string> scopes = new List<string>();
private CalendarService calendarService;
private void InitializeCalendarService()
{
//Add the calendar specific scope to the scopes list
scopes.Add(CalendarService.Scopes.Calendar.GetStringValue());
//Display the header and initialize the sample
CommandLine.EnableExceptionHandling();
CommandLine.DisplayGoogleSampleHeader("Google.Api.Calendar.v3 Sample");
//Create the authenticator
//FullClientCredentials credentials = PromptingClientCredentials.EnsureFullClientCredentials();
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
FullClientCredentials credentials = new FullClientCredentials();
credentials.ClientId = "XYZ.apps.googleusercontent.com";
credentials.ClientSecret = "XYZ";
credentials.ApiKey = "XYZ";
provider.ClientIdentifier = credentials.ClientId;
provider.ClientSecret = credentials.ClientSecret;
OAuth2Authenticator<NativeApplicationClient> auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
//Create the calendar service using an initializer instance
BaseClientService.Initializer initializer = new BaseClientService.Initializer();
initializer.Authenticator = auth;
calendarService = new CalendarService(initializer);
CalendarList list = calendarService.CalendarList.List().Execute();
//do something with the list .. the list is all good
} 
public IAuthorizationState GetAuthorization(NativeApplicationClient client)
{
//You should use a more secure way of storing the key here as
//.NET applications can be disassembled using a reflection tool.
const string STORAGE = "google.samples.dotnet.calendar";
const string KEY = "s0mekey";
//Check if there is a cached refresh token available.
IAuthorizationState state = AuthorizationMgr.GetCachedRefreshToken(STORAGE, KEY);
if ((state != null))
{
try
{
client.RefreshToken(state);
return state;
//we are done
}
catch (DotNetOpenAuth.Messaging.ProtocolException ex)
{
CommandLine.WriteError("Using an existing refresh token failed: " + ex.Message);
CommandLine.WriteLine();
}
}
//Retrieve the authorization from the user
string[] array = new string[scopes.Count];
scopes.CopyTo(array,0);
state = AuthorizationMgr.RequestNativeAuthorization(client, array);
AuthorizationMgr.SetCachedRefreshToken(STORAGE, KEY, state);
return state;
} 

Comment puis-je utiliser la même OAuth2Authenticator pour récupérer les Contacts?

Je suis en mesure de récupérer des contacts à l'aide du code ci-dessous, mais ce n'est pas sans mot de passe, j'ai besoin d'obtenir ce travail à l'aide de Oath2. L'exemple ci-dessous utilise Gdata contacts api v2. Je vois que je peux passer à travers OAuth2Authenticator, mais im pas sûr de savoir exactement comment le faire correctement (je ne peux pas voir toutes les valides des exemples en C# sur le site google) et de récupérer le code d'accès basé sur ce que l'utilisateur sélectionne.
Je ne peux pas voir comment utiliser OAuth2Authenticator avec les contacts api v3 (https://developers.google.com/google-apps/contacts/v3/)

RequestSettings rsLoginInfo = new RequestSettings("", email,pwd);
rsLoginInfo.AutoPaging = true;
ContactsRequest cRequest = new ContactsRequest(rsLoginInfo);
//fetch contacts list
Feed<Contact> feedContacts = cRequest.GetContacts();
foreach (Contact gmailAddresses in feedContacts.Entries)
{
//Looping to read  email addresses
foreach (EMail emailId in gmailAddresses.Emails)
{
lstContacts.Add(emailId.Address);
}
}
InformationsquelleAutor Marty | 2013-08-16