我正在开发一个应用程序,通过Rest端点访问自己的资源.
用户需要通过电子邮件/密码获取访问令牌.完成身份验证服务器配置后,我有这样的观察:
附:
curl client:secret@localhost:9999/uaa/oauth/token -d grant_type=password -d username=user -d password=password
Run Code Online (Sandbox Code Playgroud)
我得到了正确的答复:
{"access_token":"7541a4f6-e841-41a0-8a54-abf8e0666ed1","token_type":"bearer","refresh_token":"d3fdd7e3-53eb-4e7b-aa45-b524a9e7b316","expires_in":43199,"scope":"openid"}
Run Code Online (Sandbox Code Playgroud)
但是:
curl http://localhost:9999/uaa/oauth/token -d grant_type=password -d username=user -d password=password -d client_id=client -d client_secret=secret
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
DEBUG 4123 --- [nio-9999-exec-7] osswaExceptionTranslationFilter:访问被拒绝(用户是匿名的); 重定向到身份验证入口点
org.springframework.security.access.AccessDeniedException:org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:83)拒绝访问
当作为参数发送时,看起来不能识别client_id和client_secret.这是一个配置问题或做的OAuth2版本我使用(弹簧安全的oauth2,2.0.5.RELEASE)
我在互联网上遇到的很多例子都提出了应该使用OAuth2的方法.
谢谢 :)