@Override protected DbxRawClientV2 connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); final HttpClientBuilder configuration = builder.build(proxy, this, prompt); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService)); final CloseableHttpClient client = configuration.build(); return new CustomDbxRawClientV2(DbxRequestConfig.newBuilder(useragent.get()) .withAutoRetryDisabled() .withHttpRequestor(new DropboxCommonsHttpRequestExecutor(client)).build(), DbxHost.DEFAULT, null, null); }
private boolean authSession() { String accessToken = MyPreferences.getDropboxAuthToken(context); if (accessToken != null) { if (dropboxClient == null) { DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("financisto") .withHttpRequestor(new OkHttp3Requestor(OkHttp3Requestor.defaultOkHttpClient())) .build(); dropboxClient = new DbxClientV2(requestConfig, accessToken); } return true; } return false; }
public static void init(String accessToken) { if (sDbxClient == null || DropboxClientFactory.accessToken != accessToken) { DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder("upm") .withHttpRequestor(new OkHttp3Requestor(OkHttp3Requestor.defaultOkHttpClient())) .build(); sDbxClient = new DbxClientV2(requestConfig, accessToken); DropboxClientFactory.accessToken = accessToken; } }