Last active
August 16, 2022 16:46
-
-
Save molidev8/a9df1f0c4f8f7153972db8a6a294eb60 to your computer and use it in GitHub Desktop.
Login into the Dropbox user account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun initDropboxClient() { | |
val prefs = getSharedPreferences("recipe-vault", MODE_PRIVATE) | |
val serializedCredential = prefs.getString("credential", null) | |
if (serializedCredential == null) { | |
val credential = Auth.getDbxCredential() | |
if (credential != null) { | |
prefs.edit().putString("credential", credential.toString()).apply() | |
dropboxManager.initDropboxClient(credential) | |
} | |
} | |
} | |
fun DropboxManager.initDropboxClient(credential: DbxCredential) { | |
val newCredential = DbxCredential( | |
credential.accessToken, | |
-1L, | |
credential.refreshToken, | |
credential.appKey | |
) | |
if (client == null) { | |
client = DbxClientV2(config, newCredential) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment