Put Some Office 365 in Your Apps

MayurTendulkarMayurTendulkar Mayur TendulkarUSForum Administrator, Xamarin Team Xamurai

Hey,

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.

Mayur

Posts

  • ahmedkhanahmedkhan ahmed khan USMember, University

    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:

    http://chakkaradeep.com/index.php/office-365-api-client-libraries-authenticating-your-client-to-office-365/

    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: http://blogs.msdn.com/b/officeapps/archive/2014/03/12/announcing-office-365-api-tools-for-visual-studio-preview.aspx _ 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 @.onmicrosoft.com. 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:

    References

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

    Authentication Process: http://msdn.microsoft.com/en-us/library/office/dn605895(v=office.15).aspx

    I also tried some of the code here: https://github.com/saramgsilva/Office365InXamarinApp Ran into issues similar to those posted here http://social.msdn.microsoft.com/Forums/en-US/95c66776-79e0-4fac-9ad1-304d5fc9c070/issues-in-office-365-api-preview-xamarinandroid-xamarinios?forum=exchangesvrdevelopment

    http://stackoverflow.com/questions/24541318/nullreferenceexception-when-use-office-365-api-in-xamarin-ios/24596656#24596656

    REST based authentication option: http://stackoverflow.com/questions/24457095/office365-sharepoint-rest-api-authentication-from-xamarin-mobile-phone-app/24499406#24499406

    Sample Code (REST Authentication & Windows 8) http://code.msdn.microsoft.com/Office-365-APIs-Get-41eebcdf

    using .NET client libraries in windows 8 (it would be great if this functionality was available in Xamarin) http://code.msdn.microsoft.com/Office-365-APIs-Windows-8-63a74ba2

  • MayurTendulkarMayurTendulkar Mayur Tendulkar USForum Administrator, Xamarin 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.

    Mayur

    Xamarin-Forum.PNG
    1002 x 691 - 39K
  • ahmedkhanahmedkhan ahmed khan USMember, University

    Thanks -yes I'll keep working on it!

  • ThorstenHansThorstenHans Thorsten Hans DEMember

    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 :)

  • JaimeArroyoGarciaJaimeArroyoGarcia Jaime Arroyo Garcia ESMember

    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

    Cheers!

    J

  • JeremyThake.Microsoft.Office365JeremyThake.Microsoft.Office365 Jeremy Thake USMember

    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 Mayur Tendulkar USForum Administrator, Xamarin 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 André Lambert 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!

    André

  • BrianFraserBrianFraser Brian Fraser 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?

    Thanks,

    Brian

  • mattwardmattward Matt Ward 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 Brian Fraser 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.

    Brian

  • mattwardmattward Matt Ward 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.

  • Guido_KerstenGuido_Kersten Guido Kersten USMember
    edited December 16

    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.

    Screen Shot 2014-12-16 at 19.43.04.png
    1820 x 820 - 66K
  • MayurTendulkarMayurTendulkar Mayur Tendulkar USForum Administrator, Xamarin Team Xamurai
    edited December 17

    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.

  • Guido_KerstenGuido_Kersten Guido Kersten USMember
    edited December 17

    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.

Sign In or Register to comment.