Put Some Office 365 in Your Apps

MayurTendulkarMayurTendulkar USXamarin Team Xamurai


I've just blogged about using Office 365 client libraries in Xamarin.Android application. The blog post, 'Put Some Office 365 in Your Apps' can be read here: http://blog.xamarin.com/put-some-office-365-into-your-apps/

Do let me know your views and feedback.



  • ahmedkhanahmedkhan USUniversity ✭✭

    Thanks for the post, It would be great to get this integration working esp. considering Xamarin's close relationship with Microsoft. However It's important to note this functionality is in early preview and is pretty buggy and very sparsely documented so far IMO, so appreciate your post in that regard:

    Case in Point: I have been trying to get a Xamarin.iOS app authenticating to a sharepoint online instance using these new Office365 libraries working for nearly 2 weeks now with no luck.

    I also followed along with your post and this one to try the Office365 API on Xamarin.iOS:


    However I have been running into authentication and Visual Studio issues:

    Some background - I have an MSDN Subscription access to Azure and Office 365

    1. I created an instance of Sharepoint Online (a site collection) using my MSDN developer subscription

    2. I associated my SharePoint online site tenant with my AD instance
      see http://www.sharepointnutsandbolts.com/2014/04/using-azure-instance-behind-your-office-365-tenant.html
      AND I followed the steps here: http://blogs.technet.com/b/ad/archive/2013/09/10/empower-your-office-365-subscription-identity-management-with-application-access-enhancements-for-windows-azure-ad.aspx

    3.I used my MSDN account to setup an Azure AD instance for Office 365
    to register a client application :
    -See: http://msdn.microsoft.com/en-us/library/office/dn736059(v=office.15).aspx

    1. I installed Office365 api visual studio extension
      using these instructions:
      noting that:_

    "On the sign-in dialog box, enter the username and password for your Office 365 tenant (Figure 3). We recommend that you use your Office 365 Developer Site. Often, this user name will follow the pattern
    If you do not have a developer site, you can get a free Developer Site as part of your MSDN Benefits, or sign up for a free trial. Be aware that the user must be an admin user—but for tenants created as part of an Office 365 Developer Site, this is likely to be the case already.''

    1. However Everytime I try adding a connected service I get null object or connection errors (I tried adding another sharepoint account on azure AD instance as well but no luck)
      screenshot of error:


    SO issue link: http://stackoverflow.com/questions/25017948/trouble-using-office365-api-xamarin-ios-and-visual-studio-adding-a-connected

    Authentication Process:

    I also tried some of the code here: https://github.com/saramgsilva/Office365InXamarinApp
    Ran into issues similar to those posted here


    REST based authentication option:

    Sample Code (REST Authentication & Windows 8)

    using .NET client libraries in windows 8 (it would be great if this functionality was available in Xamarin)

  • MayurTendulkarMayurTendulkar USXamarin Team Xamurai

    Thanks for the reply Ahmed.

    I'm aware that many users are having issues integrating O365 libraries and services into their apps. And also there is limited documentation as those libraries are still in preview.

    However, I would like to suggest you to re-check your SharePoint Online/O365 configuration with Azure AD. Because, I just tried (in Visual Studio using Xamarin.Android) adding reference to O365 services and it worked for me. And I believe it can consume services too from SharePoint. I've yet to try in Xamarin.iOS though.

    Please, see attached image which shows I can successfully add O365 services to my app. Here, I'm having similar setup, i.e. personal MSDN subscription, configured with O365 Dev Account and SharePoint sites.

    Let me know if you're still facing any issues.

    Hope this helps.


  • ahmedkhanahmedkhan USUniversity ✭✭

    Thanks -yes I'll keep working on it!

  • Hey Mayur,

    are there any plans to provide O365 API as component for Xamarin Studio? I've used it with VS but regarding my current App I'd like to build an iOS only... So this is actually the only reason why I will have to power on a windows machine.... Trying to get rid of it :)

  • Hello Mayur,

    Awesome post! helped a lot!. One question though, do you happen to know if I could somehow reproduce manually the registing process of the Office API that is done in Visual Studio but in Xamarin Studio?

    I followed your instructions mimicking your solution and I managed to add the Office 365 API package from Studio and all the code seemed to be working fine except that it gave me a blank screen without authentication :(.

    Then I got my hands dirty and noticed that when you register the API from Visual Studio it adds a [assembly: Microsoft.Office365.OAuth.ClientId line in the assemblyInfo.

    I tried my luck and I added this line on Xamarin Studio and voila, Auth screen buuuut it just won't login...I guess that it detects that it is not the original app registered...so much for my hacking :(

    Any ideas would help a fellow developer 4 days ahead of a presentation and poor as a rat



  • We are working hard to ensure that the bugs that appear in the Preview will be eliminated once we go into General Availability with these Connected Services. Keep an eye on blogs.office.com for news and code samples that we'll ship very soon.

  • MayurTendulkarMayurTendulkar USXamarin Team Xamurai

    Hello Thorsten,

    Even I would love to have a component or NuGet for this API. But current VS extension does a lot of heavy work behind the scene (e.g. register the app in Azure Active Directory). Having said that, I don't have exact information on this. I'll keep posted once I get any confirmation.

  • andrelambertandrelambert BRMember

    Hi there,

    About the Office 365 mail API, anyone has any idea how to retrieve the (rfc 822) message ID from the header? I can get the ID that Microsoft supplies but I need the unique one that is common in every header.

    Thank you very much!


  • BrianFraserBrianFraser USMember

    Great article. I'm having an issue with the latest Microsoft Office 365 Authentication library released on 10/28. I get the following error when adding a connected service.

    install-package : Could not install package 'Microsoft.IdentityModel.Clients.ActiveDirectory 2.10.10910.1511'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v2.2',
    but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    I can get around this if I use the Nuget package manager to install the pre-release version from August 4. Any ideas?



  • mattwardmattward GBMember Xamurai

    The error is because the Microsoft.IdentityModel.Clients.ActiveDirectory 2.10.10910.1511 NuGet package does not have any assemblies that support MonoAndroid projects.

    The pre-release NuGet package supports both MonoAndroid and iOS Classic projects.

  • BrianFraserBrianFraser USMember

    Thanks for the response Matt. I was aware that the issue was related to the Microsoft.IdentityModel.Clients.ActiveDirectory 2.10.10910.1511 package. I was hoping that someone would have a way around this or know why Microsoft's latest package doesn't support MonoAndroid. Is this a bug or an intentional decision by Microsoft.


  • mattwardmattward GBMember Xamurai

    @BrianFraser‌ - I believe that Microsoft have only recently spent time re-developing the Microsoft.IdentifyModel.Clients.ActiveDirectory NuGet package so it supports Xamarin.

    I suspect you will not be able to extract the assembly from the non-pre-release NuGet package and use it from within an MonoAndroid project since it will likely use parts of the .NET framework not supported by MonoAndroid.

    Looking at the Office 365 Client sample GitHub repository it looks like an old version 0.1.0-alpha of the Microsoft.Office365.OAuth.Xamarin NuGet package is used which does not have a dependency on Microsoft.IdentifyModel.Clients.ActiveDirectory so you could use that instead.

    Right now the latest Office 265 OAuth Xamarin NuGet package will not install into an MonoAndroid project. Hopefully Microsoft will fix that.

  • GuidoKerstenGuidoKersten NLUniversity ✭✭
    edited December 2014

    Hi guys, I am investigating if this library is usefull for my current project. I have a Xamarin.Forms app, which support all 3 platforms.

    To test some stuff out I created a new Shared Project and I could successfully add the Office 365 service for my IOS and Android project, but when I try to do so for Windows Phone I can login with my credentials but then I get the message as shown in the image.

    So this raises a few questions for me:

    1. Is this library supported for the Windows Phone (Silverlight) project in Xamarin?

    2. If it is, can you help me understand what the message is saying or how I can resolve it?

    3. I have to login with my own Office 365 credentials to add the connected service, but is it also possible to connect to a different Office 365 environment at runtime -> the user enters his/her own credentials..? I do not understand why I have to login with my own credentials to add these libraries.

  • MayurTendulkarMayurTendulkar USXamarin Team Xamurai
    edited December 2014

    This library is well supported on Windows/Phone apps. Not sure why are you getting this message. I tried to reproduce but I couldn't. May be a wrong question but, are you logging in as admin? I'll try once again to reproduce.
    Regarding 3rd point: you're talking about multi-tenant applications. i.e. even though you register this app in your AD, when I log-in into your app, using my credentials, I should manage my O365 environment. As far as I understand, by default, native apps are multi-tenant and you don't need to do anything special.

  • GuidoKerstenGuidoKersten NLUniversity ✭✭
    edited December 2014

    Hmm well I did just gave up on trying because I read that Silverlight is not supported by these libraries in the comments of a blog? Are you sure you created a Xamarin Forms / Windows Phone Silverlight project and not a WinRT version?

    Because I tried creating a new Silverlight project and then add this service but I got the same error. I also tried to add the libraries via NuGet myself, but I could not find the platform specific part for Windows Phone, which should be something like: Microsoft.Office365.OAuth.WinPhone (My other projects reference a Microsoft.Office365.OAuth.Android and Microsoft.Office365.OAuth.iOS)

    If you did create a Silverlight project, could you maybe share this project with me, so I can maybe see any differences?

    About the multi-tenant, that is what I expected so good to hear! But I still do not understand why I have to login when adding this connected service?

    And also: I am not an admin of the O365 environment, do you think that should make a difference? I doubt it, because I don't have any problems with IOS and Android.

  • GuidoKerstenGuidoKersten NLUniversity ✭✭

    @MayurTendulkar‌ I am trying to integrate the current Office 365 API Tools (v 1.0.22) in my Xamarin Android app. I am having trouble connecting the dots here, because I can't seem to find a useful tutorial for this. Your sample project also uses an older version (0.1.0-alpha). Do you have any good point to start with? Or do you maybe have a sample project with the newer version yourself?

  • @Guido_Kersten‌ Can you follow this updated blog post to see if it helps you?

    Let me know if you have any specific questions.

  • GariceGarice ZAMember

    Hi guys

    I hope someone can help me, I am trying to create a xamarin android app that connects to office 365 to pull contact information. I am trying to follow the methods demonstrated here:


    I am able to add the connected service to my application and all the assemblies download although the sample cs files visible in the screenshot for step 4 from the tutorial(ActiveDirectorApiSample, CalendarApiSample etc) do not get added into my project. view screenshot1

    When trying to add the EnsureClientCreated() method visual studio warns me that the Authenticator namespace could not be found so I try and add it . view screenshot2

    I noticed that visual studio tries to add using Xamarin.Auth but if I check the source code from the tutorial I am following the Xamarin.Auth reference is not there:


    If I use Xamarin.Auth then visual studio throws the error in screenshot3

    can anyone confirm how I can resolve the Authenticator errors?

  • MayurTendulkarMayurTendulkar USXamarin Team Xamurai

    Hello there. The O365 tooling and API has changed a lot since this blog post last published. I'm working on updating the post with correct samples. Once it is updated, I'll post it here.
    Thanks for showing the interest.

  • GariceGarice ZAMember

    Hi Mayur

    That will be awesome, I will be waiting for the updates.


  • GariceGarice ZAMember

    Hi Mayur

    Do you think this is something you will be able to complete soon? I am working on a project for my company that requires office 365 connectivity so access to the updated information soon would really be appreciated. if not the do you have any suggestions, links etc that could help out?

  • ashianshita76ashianshita76 USMember

    back is the primary muscle by services secondary must so is almost you almost get super muscle its overlap each other so is no me to really train them the gnome to three times awake I'm I make sure their breasts I’m resting as much as I can because risks you know is wonder most important things you can do some iris probably a week between each muscle and I make sure that I'm getting real good though you know that's going to be key may she had a real good give wrong path because you are we doing begin for another week and the next question is do you dislike districts in and I can't stress this enough you know for gas this really looking to put on its size and put on a mass and .

  • MayurTendulkarMayurTendulkar USXamarin Team Xamurai

    Hello, I've recently published a blog which talks about another component of Office 365 - OneDrive for Business. It discusses about how authentication works and how new APIs can be used. There are similar kind of APIs for Outlook, SharePoint, etc... You can read it here: http://blog.xamarin.com/add-storage-to-your-apps-with-office-365/

  • addseo1118addseo1118 THMember

    Very good. that will be awesome and good info.
    Thanks you

  • tech4talltech4tall BRMember

    Thanks -yes I'll keep working on it!

Sign In or Register to comment.