Class BasicAuthDialogAuthenticator

  • All Implemented Interfaces:
    okhttp3.Authenticator

    
    public class BasicAuthDialogAuthenticator
     implements Authenticator
                        

    This class is an implementation of Authenticator (see https://square.github.io/okhttp/3.x/okhttp/okhttp3/Authenticator.html) that gets credentials from the user via a dialog. A BasicAuthCredentialStore is used to reuse credentials. The default BasicAuthCredentialStore does not persist credentials across app restarts.

    
    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    clientBuilder.authenticator(new BasicAuthDialogAuthenticator(basicAuthInMemoryStore));
    OkHttpClient okHttpClient = clientBuilder.build();
    
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static Authenticator.Companion Companion
      public final static Authenticator NONE
      public final static Authenticator JAVA_NET_AUTHENTICATOR
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Request authenticate(@Nullable() Route route, @NonNull() Response response) Overridden method, see https://square.github.io/okhttp/3.x/okhttp/okhttp3/Authenticator.html for details.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BasicAuthDialogAuthenticator

        BasicAuthDialogAuthenticator()
        A new instance of BasicAuthInMemoryStore will be used by default to store credentials for reuse.
      • BasicAuthDialogAuthenticator

        BasicAuthDialogAuthenticator(BasicAuthCredentialStore basicAuthCredentialStore)
        Allows a non-default BasicAuthCredentialStore to be specified.
        Parameters:
        basicAuthCredentialStore - This store is used so that credentials can be reused on subsequent challenges without prompting the user.
      • BasicAuthDialogAuthenticator

        BasicAuthDialogAuthenticator(BasicAuthCredentialStore basicAuthCredentialStore, boolean allowInsecureBasicAuth)
        Allows options to be specified.
        Parameters:
        basicAuthCredentialStore - This store is used so that credentials can be reused on subsequent challenges without prompting the user.
        allowInsecureBasicAuth - Allows the constructed BasicAuthDialogAuthenticator to perform basic authentication over an insecure connection (HTTP).
    • Method Detail

      • authenticate

        @Nullable() Request authenticate(@Nullable() Route route, @NonNull() Response response)

        Overridden method, see https://square.github.io/okhttp/3.x/okhttp/okhttp3/Authenticator.html for details.