public static SharePointCredentialInformation GetSharePointCredentials()
        {
            SharePointCredentialInformation credentialInformation = null;

            Windows.Storage.ApplicationDataCompositeValue composite = null;

            try
            {
                Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["SharePointCredentials"];

                if (composite != null)
                {
                    credentialInformation = new SharePointCredentialInformation()
                    {
                        RootSiteUrl = (string)composite["RootSiteUrl"],
                        UserName    = (string)composite["UserName"],
                        Password    = (string)composite["Password"],
                    };
                }
            }
            catch (Exception ex)
            {
            }

            return(credentialInformation);
        }
Example #2
0
        private async void StartSharePointAuthorization(Button button)
        {
            bool isAuthorized = false;

            button.IsEnabled = false;

            string siteUrl  = sharePointSiteUrlTextBox.Text.Trim();
            string userName = sharePointUserNameTextBox.Text.Trim();
            string password = sharePointPasswordTextBox.Password.Trim();

            SharePointCredentialInformation credentials = Core.Helpers.SettingsHelper.GetSharePointCredentials();

            if (credentials == null)
            {
                isAuthorized = await Core.Helpers.ContextHelper.ValidateCredentialsAsync(siteUrl, userName, password);

                if (isAuthorized)
                {
                    Core.Helpers.SettingsHelper.SaveSharePointCredentials(siteUrl, userName, password);
                }
            }

            button.IsEnabled = credentials == null;
        }