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);
provider
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

microsoftaccount

Microsoft Account login.

facebook

Facebook login

twitter

Twitter login

google

Google login

token
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.

useSingleSignOn
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.

 

Namespace

WindowsAzure.MobileServices

Library

MobileServices.js

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