Пример #1
0
        public async Task <bool> Authenticate(MobileServiceAuthenticationProvider authProvider)
        {
            var success = false;
            var message = string.Empty;

            try
            {
                if (authProvider.Equals(MobileServiceAuthenticationProvider.Google))
                {
                    // Sign in with Google login using a server-managed flow.
                    user = await AzureMobileServiceManager.Instance.CurrentClient.LoginAsync(this,
                                                                                             MobileServiceAuthenticationProvider.Google);
                }
                else
                {
                    // Sign in with Facebook login using a server-managed flow.
                    user = await AzureMobileServiceManager.Instance.CurrentClient.LoginAsync(this,
                                                                                             MobileServiceAuthenticationProvider.Facebook);
                }

                if (user != null)
                {
                    Settings.AuthToken = user?.MobileServiceAuthenticationToken ?? string.Empty;
                    Settings.UserId    = user?.UserId ?? string.Empty;

                    message = string.Format("you are now signed-in as {0}.",
                                            user.UserId);
                    success = true;
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            // Display the success or failure message.
            //   CreateAndShowDialog(message, "Sign-in result");

            return(success);
        }