oauth2如何refreshToken

oauth2如何refreshToken?

post请求,跟请求token一样的url地址:http://localhost:9098/oauth/token
post需要的参数:

  • grant_type :refresh_token”
  • client_id:分配的客户端id
  • client_secret:分配的客户端密码
  • refresh_token:值为上一次请求返回值中"refresh_token
    实例如下所示
    refreshtoken
    oauth2配置文件需要设置支持refreshToken
 @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        // 将token存数据库
       endpoints.tokenStore(tokenStore()).authenticationManager(authenticationManager)
                .userDetailsService(userServiceDetail);
        // 配置tokenServices参数
        DefaultTokenServices tokenServices = new DefaultTokenServices();
        tokenServices.setTokenStore(endpoints.getTokenStore());
        tokenServices.setSupportRefreshToken(true);//允许支持刷新token
        tokenServices.setClientDetailsService(endpoints.getClientDetailsService());
        tokenServices.setTokenEnhancer(endpoints.getTokenEnhancer());
        tokenServices.setAccessTokenValiditySeconds(60); // accessToken有效时间:60秒
        tokenServices.setRefreshTokenValiditySeconds(60*60*24*30);//refreshToken有效时间:30天
		tokenServices.setReuseRefreshToken(true);
        endpoints.tokenServices(tokenServices);
    }

参考文章:https://blog.csdn.net/cover_by_ht/article/details/102838581

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值