Created
November 8, 2014 06:04
-
-
Save chakkaradeep/7ce7ee0c2cbaae20ea92 to your computer and use it in GitHub Desktop.
Xamarin Android Code for Office 365 API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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