In order to improve app quality i'm working on testing: unit tests and UI tests. Since i'm having Dropbox support in the app i'd like to test it and i need to auth to Dropbox account before testing (in my android app the users are able to save the files, read them, rename, etc - basic file routines).
Dropbox provides Java/Android SDK v2 with examples but even command-line tool requires some manual actions - open browser app with the URL and select account:
// Run through Dropbox API authorization process
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-authorize");
DbxWebAuth webAuth = new DbxWebAuth(requestConfig, appInfo);
DbxWebAuth.Request webAuthRequest = DbxWebAuth.newRequestBuilder()
.withNoRedirect()
.build();
String authorizeUrl = webAuth.authorize(webAuthRequest);
System.out.println("1. Go to " + authorizeUrl);
System.out.println("2. Click \"Allow\" (you might have to log in first).");
System.out.println("3. Copy the authorization code.");
System.out.print("Enter the authorization code here: ");
String code = new BufferedReader(new InputStreamReader(System.in)).readLine();
if (code == null) {
System.exit(1); return;
}
code = code.trim();
DbxAuthFinish authFinish;
try {
authFinish = webAuth.finishFromCode(code);
} catch (DbxException ex) {
System.err.println("Error in DbxWebAuth.authorize: " + ex.getMessage());
System.exit(1); return;
}
System.out.println("Authorization complete.");
System.out.println("- User ID: " + authFinish.getUserId());
System.out.println("- Access Token: " + authFinish.getAccessToken());
Any possibility to make Dropbox auth automatically without manual interaction? I expect to provide app key/secret, account email/password and get accessToken
for the session.
PS. I'd like to avoid using Robelectric+Espresso and keep it in unit/integration tests, not in UI tests.