Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final static private String APP_KEY = "rn2qxxxx66p2";
- final static private String APP_SECRET = "t2xlsxxxxazw7";
- final static private String MYTOKEN = "M6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxECuf";
- final static private Session.AccessType ACCESS_TYPE = Session.AccessType.APP_FOLDER;
- private DropboxAPI<AndroidAuthSession> mDBApi;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_list_files);
- AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
- AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);
- mDBApi = new DropboxAPI<AndroidAuthSession>(session);
- session.setOAuth2AccessToken(MYTOKEN);
- }
- @Override
- public void onResume(){
- super.onResume();
- if (mDBApi.getSession().isLinked()) {
- try {
- //mDBApi.getSession().finishAuthentication();
- Log.i("DbAuthLog", "Authenticating OK!");
- String accessToken = mDBApi.getSession().getOAuth2AccessToken();
- Log.d("DbAuthLog",accessToken);
- Entry entry = mDBApi.metadata("/dropfiles.dat", 1, null, false, null);
- Log.d("DbAuthLog",entry.rev);
- } catch (IllegalStateException e) {
- Log.i("DbAuthLog", "Error authenticating", e);
- }catch (DropboxException e) {
- e.printStackTrace();
- }
- }else{
- Log.i("DbAuthLog", "No authenticating");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement