SALES: 1-800-867-1380
2 out of 3 rated this helpful - Rate this topic

MobileServiceClient.login function

Updated: June 20, 2013

Logs a user into a mobile service by using the specified identity provider.

mobileServiceClient.login(provider, token);
Type: string

The name of the identity provider, which instructs Mobile Services which provider to use for authentication. The following values are supported:


Provider value Description


Microsoft Account login.


Facebook login


Twitter login


Google login

Type: string

Optional JSON representation of an authentication token, which can be supplied when the client has already obtained a token from the identity provider.

Type: boolean

Indicates whether to use single sign-on when logging in. Only supported in a Windows Store app.

Type: Promise object that returns a user object when it completes.

Call the done method on the returned Promise object to access the returned user and handle any errors.

The following code authenticates the user by using a Facebook login, and then accesses the returned user ID value.

mobileService.login("facebook").done(function (results) {
    var userId = results.userId;
    // Do something with the user ID.

When you set the useSingleSignOn value to true, Mobile Services will attempt to login using credentials cached on the client. To be able to use this functionality, you must have also registered your Windows Store app package information with Mobile Services. For information on how to register your app package, see the tutorial Get started with push notifications in Mobile Services.






Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.