简体   繁体   English

okhttp 身份验证器是否处理 403 错误?

[英]Does okhttp authenticator handle 403 error?

I'm using Okhttp Authenticator for updating my JWT tokens.我正在使用Okhttp Authenticator更新我的JWT令牌。 But there is a problem, that the authenticate() method is called, when I'm getting 401 from backend.但是有一个问题,当我从后端获取 401 时,调用了authenticate()方法。 But when I'm getting 403 - token expired, the authenticate() method doesn't get called.但是当我收到 403 - token expired 时,不会调用authenticate()方法。 Is there any good topic about how the authenticator() method works or can we call it manually?关于authenticator()方法的工作原理有什么好的话题吗?或者我们可以手动调用它吗? And also the main question - does it handle 403 response?还有一个主要问题——它是否处理 403 响应?

You can add your own interceptor to catch the 403, renew the token and retry.您可以添加自己的拦截器来捕获 403,更新令牌并重试。

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这基本上就是我项目中的这个拦截器所做的https://github.com/yschimke/okurl/blob/5163436f8bcb2526e8be7b72d59d99a9db433848/src/main/kotlin/com/baulsupp/okurl/authenticator/RenewingInter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM