Advertisement
Guest User

Untitled

a guest
Jan 21st, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. final static private String APP_KEY = "rn2qxxxx66p2";
  2.     final static private String APP_SECRET = "t2xlsxxxxazw7";
  3.     final static private String MYTOKEN = "M6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxECuf";
  4.     final static private Session.AccessType ACCESS_TYPE = Session.AccessType.APP_FOLDER;
  5.     private DropboxAPI<AndroidAuthSession> mDBApi;
  6.     @Override
  7.     protected void onCreate(Bundle savedInstanceState) {
  8.         super.onCreate(savedInstanceState);
  9.         setContentView(R.layout.activity_list_files);
  10.  
  11.         AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
  12.         AndroidAuthSession session = new AndroidAuthSession(appKeys, ACCESS_TYPE);
  13.         mDBApi = new DropboxAPI<AndroidAuthSession>(session);
  14.         session.setOAuth2AccessToken(MYTOKEN);
  15. }
  16.  
  17. @Override
  18.     public void onResume(){
  19.         super.onResume();
  20.         if (mDBApi.getSession().isLinked()) {
  21.             try {
  22.  
  23.                 //mDBApi.getSession().finishAuthentication();
  24.                 Log.i("DbAuthLog", "Authenticating OK!");
  25.                 String accessToken = mDBApi.getSession().getOAuth2AccessToken();
  26.                 Log.d("DbAuthLog",accessToken);
  27.                 Entry entry = mDBApi.metadata("/dropfiles.dat", 1, null, false, null);
  28.                 Log.d("DbAuthLog",entry.rev);
  29.             } catch (IllegalStateException e) {
  30.                 Log.i("DbAuthLog", "Error authenticating", e);
  31.             }catch (DropboxException e) {
  32.                 e.printStackTrace();
  33.             }
  34.     }else{
  35.             Log.i("DbAuthLog", "No authenticating");
  36.         }
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement