草庐IT

WebTokens

全部标签

android - 为 WebTokens 身份验证改造自定义客户端

我正在使用Retrofit来处理与服务器API的通信,API用户使用JSONWebTokens进行身份验证。token有时会过期,我正在寻找实现可在token过期时自动刷新token的RetrofitClient的最佳方法。这是我想出的初步实现,:/***ClientimplementationthatrefreshesJSONWebTokenautomaticallyif*theresponsecontainsa401header,hastheremaybesimultaneouscallstoexecutemethod*therefreshTokenissynchronizedto