【发布时间】:2017-06-10 19:21:56
【问题描述】:
我创建了一个拥有授权和资源服务器的 Spring Boot 应用程序,这是我的主类:
@SpringBootApplication
@EnableResourceServer
@EnableAuthorizationServer
public class OauthServerApplication {
public static void main(String[] args) {
SpringApplication.run(OauthServerApplication.class, args);
}
}
这是我的 application.yml:
security:
user:
name: guest
password: guest123
oauth2:
client:
client-id: trustedclient
client-secret: trustedclient123
authorized-grant-types: authorization_code,refresh_token,password
scope: openid
要生成访问令牌,我只执行这个 url (POST):
http://trustedclient:trustedclient123@localhost:8080/oauth/token?username=guest&password=guest123&grant_type=password
返回:
{
"access_token": "f2e722b7-3807-4a27-9281-5b28b7bd3d0d",
"token_type": "bearer",
"refresh_token": "f96d472c-8259-42e2-b939-4963dfeeb086",
"scope": "openid"
}
现在我需要知道如何验证令牌是否正确,有什么帮助吗?
【问题讨论】:
-
为什么您响应令牌请求获得的令牌无效?
-
我不是说无效,我想把这个token交给客户端,然后验证token是否正确,如果无效我会拒绝请求
标签: spring-boot oauth-2.0