Oauth 2.0 为/oauth/token配置基本身份验证

Oauth 2.0 为/oauth/token配置基本身份验证,oauth-2.0,spring-cloud,spring-security-oauth2,spring-oauth2,Oauth 2.0,Spring Cloud,Spring Security Oauth2,Spring Oauth2,我想使用SpringCloud为OAuth2实现令牌刷新 我可以通过使用此有效负载向/oauth/token发送请求来创建令牌: curl --location --request POST 'http://localhost:8080/engine/oauth/token' \ --header 'Authorization: Basic YWRtaW46cXdlcnR5' \ --form 'username=admin' \ --form 'password=qwerty' \ --for

我想使用SpringCloud为OAuth2实现令牌刷新

我可以通过使用此有效负载向
/oauth/token
发送请求来创建令牌:

curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--form 'username=admin' \
--form 'password=qwerty' \
--form 'grant_type=password' \
--form 'scope=read'
curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--form 'grant_type=refresh_token' \
--form 'scope=read' \
--form 'refresh_token=....'
但对于刷新令牌,使用相同的路径
/oauth/token
。我还需要将用户名和密码发送到标题
“Authorization:Basic YWRtaW46cXdlcnR5”
,但我没有。我可以使用具有此有效负载的刷新令牌创建新令牌:

curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--form 'username=admin' \
--form 'password=qwerty' \
--form 'grant_type=password' \
--form 'scope=read'
curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--form 'grant_type=refresh_token' \
--form 'scope=read' \
--form 'refresh_token=....'
你知道如何解决这个问题吗


Github

刷新令牌授予消息不需要授权标头。请尝试将其删除,并将客户端id作为表单参数发送。您可能还需要配置脱机\u访问范围,以便令牌刷新正常工作

不过,我记得的最后一点是,ROPC不应该支持令牌刷新,尽管并非所有提供者都支持令牌刷新

最后,请注意,如果您有更好的选择,ROPG实际上并不推荐。总结问题


如果你能总结一下你的使用场景,我可能会推荐一个更好的替代方案。

我得到“错误描述”:“无效范围:脱机访问”,你需要先在授权服务器中配置该范围,然后从客户端发送。仍然不能保证它能与ROPG一起工作,默认情况下,每次都应该发送凭证。关于使用场景:我有一个Angular SPA,它需要能够连接到Spring云应用程序,并使用OAuth2安全性获取一些数据。我需要进行令牌刷新和令牌撤销。看看这个项目的链接,看看我到目前为止做了些什么。啊,你有一个服务器端的web应用程序来做安全保护。在这种情况下,授权代码流是正确的——如中所示。不过,我的首选是在SPA中执行安全客户端,这可能具有许多架构优势。如果对这种方法感兴趣,也许可以与您的同事讨论,看看我的