Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does okhttp authenticator handle 403 error?

I'm using Okhttp Authenticator for updating my JWT tokens. But there is a problem, that the authenticate() method is called, when I'm getting 401 from backend. But when I'm getting 403 - token expired, the authenticate() method doesn't get called. Is there any good topic about how the authenticator() method works or can we call it manually? And also the main question - does it handle 403 response?

like image 528
Hayk Mkrtchyan Avatar asked Aug 08 '26 16:08

Hayk Mkrtchyan


1 Answers

You can add your own interceptor to catch the 403, renew the token and retry.

It's essentially what this interceptor in my project does https://github.com/yschimke/okurl/blob/5163436f8bcb2526e8be7b72d59d99a9db433848/src/main/kotlin/com/baulsupp/okurl/authenticator/RenewingInterceptor.kt

like image 130
Yuri Schimke Avatar answered Aug 11 '26 07:08

Yuri Schimke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!