【发布时间】:2016-06-12 04:15:40
【问题描述】:
我已经使用 oAuth2 实现了 Spring 安全性。我想在访问令牌过期之前刷新它。请帮助我如何请求刷新我的访问令牌。
【问题讨论】:
标签: spring-security oauth-2.0 spring-security-oauth2 jhipster
我已经使用 oAuth2 实现了 Spring 安全性。我想在访问令牌过期之前刷新它。请帮助我如何请求刷新我的访问令牌。
【问题讨论】:
标签: spring-security oauth-2.0 spring-security-oauth2 jhipster
oauth/token?grant_type=refresh_token&client_id=[id]&client_secret=[secret]&refresh_token=[your refresh token]
像上面一样发送请求。您应该在请求中添加客户详细信息。
【讨论】:
你可以向oauth/token发出POST请求,见AngularJS sn-p如下:
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
【讨论】: