OkHttp Interceptors in Android

Learn how to use OkHttp Interceptors to intercept network requests, log them and also modify them on the fly. By Subhrajyoti Sen.

Leave a rating/review
Download materials
Save for later
Comments
Share

Learning path

This is part of the Advanced Android Data & Networking learning path. View path.

Who is this for?

This course is for Android developers who want to monitor and modify network calls at the application and network levels, in turn simplifying network operations.

Covered concepts

  • Initializing OkHttp Interceptors
  • Choosing between Application and Network Interceptors
  • Logging network data with different log levels
  • Redacting sensitive information from network logs
  • Debugging network errors
  • Adding authentication token to all API calls
  • Adding custom headers useful for analytics

Part 1: Implementing OkHttp Interceptors

01
Toggle description

Find out what OkHttp Interceptors are. Learn the difference between Application and Network Interceptors.

Toggle description

Generate a TheMovieDB API key and use it to get the starter project running.

Log and debug API calls by implementing a custom Interceptor. Learn about the different logging levels.

Use a custom logging client to control how the Interceptor logs the API calls and also redact sensitive information from the logs.

Toggle description

Implement an Interceptor that adds the API key to all API calls and avoid duplication of effort.

Toggle description

Learn how to implement an Interceptor to add custom headers that are useful for analytics.

Up next

Android & Kotlin
Android DataStore
DataStore is Google’s new and improved solution for persisting simple pieces of data by using either key-v... more

Instructors

Contributors

Filip Babić

Tech Editor

Adriana Kutenko

Illustrator

Over 300 content creators. Join our team.