odk*_*dke 5 java token jwt spring-boot
我已经按照本指南https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/在我的 Web 应用程序中实现访问令牌,它工作正常。但是,本指南没有提及有关刷新令牌的任何内容。
任何人都可以帮助我了解如何在 Java Spring Boot 中实现这一点吗?或者有没有其他方法可以让用户保持登录状态?
小智 5
如果配置正确,Spring 会提供获取新访问令牌的功能,即如果authorizedGrantTypes包含"refresh_code".
您应该使用刷新令牌通过使用令牌端点来获取新的访问令牌,如下所示:
curl -H "Authorization: Bearer [base64encode(clientId:clientSecret)]" "https://yourdomain.com/oauth/token?grant_type=refresh_token&refresh_token=[yourRefreshToken]"
Run Code Online (Sandbox Code Playgroud)
例子:
curl -X POST -H 'Authorization: Basic dGVzdGNsaWVudDpzZWNyZXQ=' -d 'refresh_token=fdb8fdbecf1d03ce5e6125c067733c0d51de209c&grant_type=refresh_token' localhost:3000/oauth/token
{
"token_type":"bearer",
"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiVlx1MDAxNcKbwoNUwoonbFPCu8KhwrYiLCJpYXQiOjE0NDQyNjI4NjYsImV4cCI6MTQ0NDI2Mjg4Nn0.Dww7TC-d0teDAgsmKHw7bhF2THNichsE6rVJq9xu_2s",
"expires_in":20,
"refresh_token":"7fd15938c823cf58e78019bea2af142f9449696a"
}
Run Code Online (Sandbox Code Playgroud)
如此处所述:https : //auth0.com/blog/refresh-tokens-what-are-they-and-when-to-use-them/
| 归档时间: |
|
| 查看次数: |
16741 次 |
| 最近记录: |