1
0
mirror of https://github.com/etesync/android synced 2024-11-16 04:49:06 +00:00

HttpUrl: Add a way to create from string host and auth token.

This commit is contained in:
Tom Hacohen 2017-04-06 16:50:31 +01:00
parent d41b7827ee
commit dd425ecbe2

View File

@ -47,16 +47,21 @@ public class HttpClient {
private HttpClient() {
}
public static OkHttpClient create(@Nullable Context context, @NonNull Account account, @NonNull final Logger logger) throws InvalidAccountException {
public static OkHttpClient create(@Nullable Context context, @NonNull final Logger logger, @Nullable String host, @NonNull String token) {
OkHttpClient.Builder builder = defaultBuilder(context, logger);
// use account settings for authentication
AccountSettings settings = new AccountSettings(context, account);
builder = addAuthentication(builder, Constants.serviceUrl.getHost(), settings.getAuthToken());
builder = addAuthentication(builder, host, token);
return builder.build();
}
public static OkHttpClient create(@Nullable Context context, @NonNull Account account, @NonNull final Logger logger) throws InvalidAccountException {
// use account settings for authentication
AccountSettings settings = new AccountSettings(context, account);
return create(context, logger, Constants.serviceUrl.getHost(), settings.getAuthToken());
}
public static OkHttpClient create(@NonNull Context context, @NonNull Logger logger) {
return defaultBuilder(context, logger).build();
}