Spring security 如何引用oAuth2令牌+;春季安全
我已经用oAuth2实现了Spring安全性。我想在访问令牌过期之前刷新它。请帮助我如何请求刷新我的访问令牌。您可以向oauth/token发出POST请求,请参阅以下AngularJS片段:Spring security 如何引用oAuth2令牌+;春季安全,spring-security,oauth-2.0,spring-security-oauth2,jhipster,Spring Security,Oauth 2.0,Spring Security Oauth2,Jhipster,我已经用oAuth2实现了Spring安全性。我想在访问令牌过期之前刷新它。请帮助我如何请求刷新我的访问令牌。您可以向oauth/token发出POST请求,请参阅以下AngularJS片段: function ajaxRefreshToken(refresh_token) { return $injector.get('$http') .post( 'oauth/token', 'grant
function ajaxRefreshToken(refresh_token) {
return $injector.get('$http')
.post(
'oauth/token',
'grant_type=refresh_token&refresh_token=' + refresh_token,
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
'Authorization': 'Basic ' + Base64.encode('***' + ':' + '***')
}
});
}
或者,使用cURL:
curl -s -u $CLIENT_ID:$SECRET \
'http://$HOST/oauth/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data 'grant_type=refresh_token&refresh_token='$REFRESH_TOKEN
像上面那样发送请求。您应该在请求中添加客户端详细信息。Hi@francescou,我通过请求{“error”:“unauthorized”,“error\u description”:“需要完全身份验证才能访问此资源”}。我现在收到此异常{“error”:“server\u error”,“error\u description”:“UserDetails服务是必需的”。}你是在用你的clientId和clientSecret替换这两个***吗?@sdoxsee:是的,我在之前的示例中添加了一个cURL示例comment@charnjeet-singh:请写完整的stacktraceHi我现在得到这个异常{“error”:“server\u error”,“error\u description”:“UserDetails服务是必需的”。}
oauth/token?grant_type=refresh_token&client_id=[id]&client_secret=[secret]&refresh_token=[your refresh token]