Dropbox Core and Sync APIs together in Android App -
is possible use both core , sync api in 1 android app?
it possible use them together. it's 2 part setup.
removing project errors:
- add jar files both sdks project
- now open dropbox core sdk jar file , remove
client2.authclasses - that's causing namespace collision. see errors until fixed
authenticating sdks:
- setup dropbox linking sync sdk - there many docs on this
get oauth credentials sync sdk core sdk using:
appkeypair appkeypair = new appkeypair(app_key, app_secret); androidauthsession session = new androidauthsession(appkeypair); session.setoauth2accesstoken(gettokenfromsyncapi()); session.finishauthentication();
and finally, missing method:
string gettokenfromsyncapi() { string token = null; string alltokens = getapplicationcontext().getsharedpreferences("dropbox-credentials", context.mode_private).getstring("accounts", null); try { jsonarray jsonaccounts = new jsonarray(alltokens); if (jsonaccounts.length() > 0) { string tmptoken = null; tmptoken = jsonaccounts.getjsonobject(0).getstring("usertoken"); // take oauth2 tokens if (tmptoken.startswith("|oa2|")) token = tmptoken.substring(5); } } catch (jsonexception e) { e.printstacktrace(); } return token; } method courtesy : https://blogs.dropbox.com/developers/2015/05/migrating-sync-sdk-access-tokens-to-core-sdk/
ps : method shown @ link has bug. substring(6) instead of 5
Comments
Post a Comment