Skip to content

Commit

Permalink
doc: cleanup readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rburgst committed Aug 4, 2023
1 parent 8d41c7b commit 3a74f89
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ If you want to support multiple authentication schemes (including auth caching)
work:

```java
OkHttpClient.Builder builder = new OkHttpClient.Builder();
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
final Map<String, CachingAuthenticator> authCache = new ConcurrentHashMap<>();

Credentials credentials = new Credentials("username", "pass");
final Credentials credentials = new Credentials("username", "pass");
final BasicAuthenticator basicAuthenticator = new BasicAuthenticator(credentials);
final DigestAuthenticator digestAuthenticator = new DigestAuthenticator(credentials);

Expand All @@ -47,24 +47,26 @@ DispatchingAuthenticator authenticator = new DispatchingAuthenticator.Builder()
.with("basic", basicAuthenticator)
.build();

client = builder
final OkHttpClient client = builder
.authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
.addInterceptor(new AuthenticationCacheInterceptor(authCache,new DefaultRequestCacheKeyProvider()))
.addInterceptor(new AuthenticationCacheInterceptor(authCache, new DefaultRequestCacheKeyProvider()))
.addNetworkInterceptor(logger)
.build();
```
If you want to cache Proxy credentials, you need to add a NetworkInterceptor :

```java
client = builder
final OkHttpClient client = builder
.authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
.addNetworkInterceptor(new AuthenticationCacheInterceptor(authCache,new DefaultProxyCacheKeyProvider()))
.addNetworkInterceptor(new AuthenticationCacheInterceptor(authCache, new DefaultProxyCacheKeyProvider()))
.addNetworkInterceptor(logger)
.build();
```
You can also combine Proxy AND Web site Authentication :

You can also combine Proxy AND Web site Authentication :

```java
client = builder
final OkHttpClient client = builder
.authenticator(new CachingAuthenticatorDecorator(authenticator, authCache))
.addNetworkInterceptor(new AuthenticationCacheInterceptor(authCache,new DefaultProxyCacheKeyProvider()))
.addInterceptor(new AuthenticationCacheInterceptor(authCache,new DefaultRequestCacheKeyProvider()))
Expand Down

0 comments on commit 3a74f89

Please sign in to comment.