私は許可およびリソースのサーバーを持っている春のブートアプリケーションを作成し、これは私のメインクラスです:OAuthサーバーからトークンを検証する方法は?
@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:[email protected]: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"
}
今、トークンが正しいかどうかを確認する方法を知る必要があります。
https://github.com/Baeldung/spring-security-oauthは、なぜあなたはあなたのトークン要求に応じて取得するトークンが無効になり、このチュートリアルを参照してください? –
私はそれが無効であると言っているわけではありません、私はこのトークンをクライアントに与えて、トークンが正しいかどうかを検証したいのですが、無効な場合にはその要求を拒否します –