# Basic Auth with OkHttp and Retrofit

DevFeed: [Basic Auth with OkHttp and Retrofit](<https://devfeed.tech/articles/basic-auth-with-okhttp-and-retrofit-22649.md>)

Original publisher: [Read original article](<https://www.valueof.io/blog/basic-auth-okhttp-retrofit-dagger>)

Author: James Shvarts

Published: 2022-11-05T22:25:12Z

Content type: tutorial

Language: en

Sources: [Android Blog - Mobile Dev Notes](<https://devfeed.tech/sources/android-blog-mobile-dev-notes.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [client library](<https://devfeed.tech/topics/client-library.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [annotations](<https://devfeed.tech/tags/annotations.md>), [api](<https://devfeed.tech/tags/api.md>), [auth](<https://devfeed.tech/tags/auth.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [basic](<https://devfeed.tech/tags/basic.md>), [configure](<https://devfeed.tech/tags/configure.md>), [custom](<https://devfeed.tech/tags/custom.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dagger-hilt](<https://devfeed.tech/tags/dagger-hilt.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [header](<https://devfeed.tech/tags/header.md>), [hilt](<https://devfeed.tech/tags/hilt.md>), [http](<https://devfeed.tech/tags/http.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-android](<https://devfeed.tech/tags/kotlin-android.md>), [okhttp](<https://devfeed.tech/tags/okhttp.md>), [project](<https://devfeed.tech/tags/project.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>)

## AI overview

The post outlines a Kotlin Android example that uses OkHttp and Retrofit for an HTTP GET request to an endpoint requiring Basic Authentication. It describes routing outgoing requests through a custom component that sets the authentication header, then wiring the repository interface and implementation through Dagger/Hilt for use in a ViewModel. Moshi is listed for JSON handling, with its annotations tied to the API contract. The excerpt does not include the code or specify the exact header construction.

## Source excerpt

Basic Auth example using OkHttp, Retrofit, Dagger in a Kotlin project