title: Retrofit and OkHttp basic authentication
body: <p>I am trying to add basic authentication (username and password) to a Retrofit OkHttp client. This is the code I have so far:</p>
  
  <pre><code>private static Retrofit createMMSATService(String baseUrl, String user, String pass) {
      HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
      interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
      OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
  
      Retrofit retrofit = new Retrofit.Builder()
              .baseUrl(baseUrl)
              .client(client)
              .addConverterFactory(GsonConverterFactory.create())
              .build();
  
      return retrofit;
  }
  </code></pre>
  
  <p>I am using Retrofit 2.2 and <a href="https://futurestud.io/tutorials/android-basic-authentication-with-retrofit" rel="noreferrer">this tutorial</a> suggests using <code>AuthenticationInterceptor</code>, but this class is not available.
  Where is the correct place to add the credentials? Do I have to add them to my interceptor, client or Retrofit object? And how do I do that?</p>