Java 用弹簧安全装置固定休息

Java 用弹簧安全装置固定休息,java,spring-security,oauth-2.0,spring-boot,Java,Spring Security,Oauth 2.0,Spring Boot,我在运行这个项目时遇到了一些问题。我克隆了它并运行mvn spring boot:run,一旦Tomcat在端口8080上启动,我就从浏览器访问它: http://localhost:8080/greeting 但是它说,在SecurityContextunauthorized中找不到身份验证对象解决方案是访问资源: curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: applicati

我在运行这个项目时遇到了一些问题。我克隆了它并运行
mvn spring boot:run
,一旦Tomcat在端口8080上启动,我就从浏览器访问它:

http://localhost:8080/greeting

但是它说,
在SecurityContextunauthorized中找不到身份验证对象

解决方案是访问资源:

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=spring&username=roy&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp"
回应如下:

{"access_token":"ff16372e-38a7-4e29-88c2-1fb92897f558","token_type":"bearer","expires_in":43199,"scope":"read write"}
并将令牌放入:

curl http://localhost:8080/greeting -H "Authorization: Bearer ff16372e-38a7-4e29-88c2-1fb92897f558"

你有没有调查过?403响应意味着你的应用程序正在运行并且是安全的(对于未经验证的请求,我可能更喜欢401)。那么问题出在哪里呢?@DaveSyer我的错,我没有走到正确的过程。。不管怎样,我也用Spring Boot GAE*应用程序引擎尝试/移植了它,但安全性没有启动