0
votes

I am trying to build a cross platform (Android, iOS, Windows) mobile application using Xamarin Forms PCL project library. My requirements are simple yet involves a lot of services which I find to tie together.

Here is the mix of services that I want to use

  • Xamarin Forms
  • Azure AD to Authenticate against (Office 365 tenant)
  • Mobile Services Client with offline sync capablity
  • Azure Mobile AppService .NET backend
  • SharePoint Online to perform CRUD operations on List on behalf of the user

I want to look at some samples or reference implementation with this combination.

I have been struggling with this combination, in fact I got AD Auth to work with Xamarin forms PCL using some pre-release version of ADAL NuGet package, the latest stable version does not work. Similarly I also for the App directly communicate with SharePoint REST APIs but now that the Auth is broken I am not able to proceed.

Then I thought of using Azure Mobile App .NET Backend, now I got Auth working there but when a call is made to the mobile backend I am not able to access SharePoint list (CSOM) since the Auth is only to access the backend service, unable to impersonate as the user to access SP. I guess I need to use AppAuth but that too not working.

I realise that instead of focusing on my actual problem of building the App I am not exploring different ways to get the AD Auth and SharePoint Access working. Can anyone point to any reference to help me out here.

1
What do you mean by latest stable does not work? We recently GA adal v3. Are you saying 3.10 has issues for you? - Kanishk Panwar
You should consider the SharePoint List and the Mobile Apps backend as two distinct services, served by the same authentication request. Get ADAL + Xamarin.Forms working first, then authenticate separately (using the same key) to both Azure Mobile Apps and SharePoint. There is no offline sync with SharePoint Lists. - Adrian Hall
@KanishkPanwar-MSFT Yes, I am talking about 3.10... I got AD Auth working with a pre-release version 3.5.xxx303. But I am not able to upgrade to 3.10 it says cannot add to PCL targeting .net 4.5 - Nithyanand K N
@AdrianHall I managed to get Xamarin Forms + ADAL v3.5.xxx303 working. And then created a Azure Mobile App backend which also uses the same O365 AD for Auth. When mobile client calls the backend I can see that it request is authenticated but I want to connect to SP and insert list item as the authenticated user. That is where I'm having problem. I get a 400 error. - Nithyanand K N
What profile are you targeting? We do not support Windows phone 8.1 to be clear. - Kanishk Panwar

1 Answers

0
votes

I suspect you have a problem in your AAD setup. I assume you're using ADAL to do client-directed login on your Xamarin forms client. If so, then what you need to do is set up 2 Active Directory apps, one for the native client, and one for the web backend.

Here's a sample that's for mobile services that shows a similar setup, but for Dynamics CRM: Mobile Services Dynamics Connector Setup

The main point is that you need to set up your client app registration with the following permissions. Assuming your backend registration is MobileBackend:

Client app permissions:

  • Azure Active Directory: Enable sign-on and read users' profiles
  • MobileBackend: Access MobileBackend

MobileBackend will have the following permissions:

  • Azure Active Directory: Enable sign-on and read users' profiles
  • Sharepoint: The sharepoint permissions you need

Once you've done all this, use this article for Xamarin authentication: Authenticate users with the Active Directory Authentication Library.