--

Very interesting article. I've a question, in my network layer I have only one `runBlocking` operation and so far I haven't found a workaround:

I have a `okhttp3.Authenticator` and I must override the `authenticate` method (not suspended) in order to refresh a token in a HTTP 401 situation:

```

override fun authenticate(route: Route?, response: Response): Request? {

...

val newToken: String? = runBlocking {

return@runBlocking runCatching {

manager.revalidateToken()

}.onSuccess {

return@runBlocking it

}.getOrNull()

}

return if (newToken.isNullOrEmpty()) null else ...

}

```

The method revalidateToken() is suspend.

How would you solve this situation? Thanks.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Guilherme Delgado
Guilherme Delgado

Written by Guilherme Delgado

Software Engineer at BlissApplications 🇵🇹 • github.com/GuilhE • When I’m not coding I’m 🧗🏽or 🏄‍♂️

Responses (1)

Write a response