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().authenticationSuccessful()) {
- try {
- // Required to complete auth, sets the access token on the session
- mDBApi.getSession().finishAuthentication();
- Log.i("DbAuthLog", "Authenticating OK!");
- } catch (IllegalStateException e) {
- Log.i("DbAuthLog", "Error authenticating", e);
- }
- }else{
- Log.i("DbAuthLog", "No authenticating");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement