首页 文章

如何改进oAuth2令牌 spring 安全性

提问于
浏览
0

我用oAuth2实现了Spring安全性 . 我希望在它到期之前刷新我们的访问令牌 . 请帮我刷新访问令牌的请求 .

2 回答

  • 0

    您可以对oauth / token发出POST请求,请参阅以下AngularJS代码段:

    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
    
  • 0
    oauth/token?grant_type=refresh_token&client_id=[id]&client_secret=[secret]&refresh_token=[your refresh token]
    

    发送请求如上所述 . 您应该在请求中添加客户端详细信息 .

相关问题