Skip to content

Instantly share code, notes, and snippets.

@chakkaradeep
Created November 8, 2014 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chakkaradeep/7ce7ee0c2cbaae20ea92 to your computer and use it in GitHub Desktop.
Save chakkaradeep/7ce7ee0c2cbaae20ea92 to your computer and use it in GitHub Desktop.
Xamarin Android Code for Office 365 API
async void GetContacts()
{
DiscoveryClient discoveryClient = new DiscoveryClient(discoveryServiceEndpointUri,
() =>
{
var authResult = authContext.AcquireTokenSilentSync(discoveryServiceResourceId, ClientId, AadUserInfo.UserId);
return authResult.AccessToken;
});
var dcr = await discoveryClient.DiscoverCapabilityAsync("Contacts");
OutlookServicesClient outlookContactsClient = new OutlookServicesClient(dcr.ServiceEndpointUri,
async () =>
{
var authResult = authContext.AcquireTokenSilentSync(dcr.ServiceResourceId, ClientId, AadUserInfo.UserId);
return await Task.FromResult<string>(authResult.AccessToken);
});
var c = await outlookContactsClient.Me.Contacts.ExecuteAsync();
var cs = c.CurrentPage;
foreach (var ci in cs)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetMessage(ci.DisplayName);
builder.SetTitle("Contact");
builder.SetCancelable(false);
builder.SetPositiveButton("OK", (sender, args) => { });
builder.Create().Show();
}
if(AadUserInfo == null)
{
AadUserInfo = new UserInfo();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment