Пример #1
0
        private string GetDropboxToken()
        {
            string accessToken = Settings.Default.AccessToken;

            if (string.IsNullOrEmpty(accessToken))
            {
                WebAuth dialog = new WebAuth(ConsumerKey, ConsumerSecret);
                dialog.ShowDialog();
                if (dialog.Result)
                {
                    accessToken = dialog.Token.access_token;
                    Settings.Default.AccessToken = accessToken;
                    Settings.Default.Uid         = dialog.Token.uid;

                    Settings.Default.Save();
                }
                else
                {
                    MessageBox.Show("Could not authenticate to Dropbox", "Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    throw new UnauthorizedAccessException("Dropbox authentication failed.");
                }
            }
            return(accessToken);
        }