Azure Mobile Services supports both client-driven and server-driven authentication methods. Server-driven authentication uses identity providers, including Microsoft Account. When you use a Microsoft Account with server-driven authentication without registering your app with Mobile Services, users are prompted to supply credentials every time that the authentication is requested. When you register your app, the Microsoft Account login credentials are cached and can be used for authentication without the user being prompted to supply them again. This topic shows you how to register your Windows Store app package for an improved Microsoft Account login experience when using Azure Mobile Services for authentication.
Visual Studio 2013 makes it easy to register your Windows Store app package with Mobile Services. For more information, see Quickstart: Adding push notifications for a mobile service in the Windows Dev Center.
Client-managed authentication can be used to provide a single sign-on experience on a Windows device by using Live Connect. If you use Live Connect APIs, you do not need to complete the steps in this topic. For more information, see Authenticate your Windows Store app with Live Connect single sign-on.
If you have not already registered your app, navigate to the Submit an app page at the Dev Center for Windows Store apps, log on with your Microsoft account, and then click App name.
Select Create a new app by reserving a unique name and click Continue, then type a name for your app in App name, click Reserve app name, and then click Save.
This creates a new Windows Store registration for your app.
In Visual Studio, open the project that you created when you completed the tutorial Get started with Mobile Services.
In solution explorer, right-click the Windows Store app project, click Store, and then click Associate App with the Store....
This displays the Associate Your App with the Windows Store Wizard.
In the wizard, click Sign in and then login with your Microsoft account, select the app that you registered in step 2, click Next, and then click Associate.
This adds the required Windows Store registration information to the application manifest.
(Optional) For a universal Windows app, repeat steps 4 and 5 for the Windows Phone Store project.
Back in the Windows Dev Center page for your new app, click Services.
In the Services page, click Live Services site under Azure Mobile Services.
Click API Settings, select enable Mobile or desktop client app, supply the mobile service URL as the Target domain, supply a value of
https://<mobile_service>.azure-mobile.net/login/microsoftaccount/ in Redirect URL, then click Save.
In App settings, make a note of the values of Client ID, Client secret, and Package security identifier (SID).
Log on to the Azure Management Portal, click Mobile Services, and then click your app.
Click the Identity tab, enter the Client Secret and Package SID values obtained from WNS in Step 4, and then click Save.
Click the Identity tab. Notice the Client Secret and Package SID values are already set from the previous step. Enter the Client ID you previously made note of, and then click Save.
You are now ready to use a Microsoft account for authentication in your app.
After you have registered your app package, remember to supply a value of true for the useSingleSignOn when you call the LoginAsync method. This provides your users with the improved login experience when using a Microsoft Account.