static public Boolean WriteDropbox(String AppKey, String AppSecret, String fileNamePath) { DBFileNamePath = fileNamePath; try { // If the authorizing process has already been started if (DBAuthStart) { // Writes to Dropbox must be a thread. Android reuqirement ThreadPool.QueueUserWorkItem(o => writeDB()); } // If the authorizing process has not been done yet if (!DBAuthStart) { DBAuthStart = true; AppKeyPair appKeys = new AppKeyPair(AppKey, AppSecret); AndroidAuthSession session = new AndroidAuthSession(appKeys); dropboxApi = new DropboxApi(session); (dropboxApi.Session as AndroidAuthSession).StartOAuth2Authentication(MainActivity.mainContext); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("***** WriteDropbox failed: " + e.ToString()); System.Diagnostics.Debug.WriteLine("***** DBAuthStart: " + DBAuthStart); return(false); } return(true); }
private void StartDropboxAuthActivity() { AppKeyPair appKeys = new AppKeyPair(AppKey, AppSecret); _session = new AndroidAuthSession(appKeys); _dropboxApi = new DropboxApi(_session); _session.StartOAuth2Authentication(this); }
public static DropboxApi GetDBApi(Context context) { var appKeys = new AppKeyPair(AppKey, AppSecret); AndroidAuthSession session; if (PreferenceManager.GetDefaultSharedPreferences(context).Contains(PrefDropboxToken)) { session = new AndroidAuthSession(appKeys, PreferenceManager.GetDefaultSharedPreferences(context).GetString(PrefDropboxToken, "")); } else { session = new AndroidAuthSession(appKeys); } return new DropboxApi(session); }
protected override void OnStart() { base.OnStart(); AppKeyPair appKeys = new AppKeyPair(AppKey, AppSecret); AndroidAuthSession session = new AndroidAuthSession(appKeys); if (File.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + "dropboxKey.txt")) { session.OAuth2AccessToken = File.ReadAllText(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + "dropboxKey.txt"); } dropboxApi = new DropboxApi(session); if (!File.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/" + "dropboxKey.txt")) { (dropboxApi.Session as AndroidAuthSession).StartOAuth2Authentication(this); } }