Token introspection với Spring Authorization Server

Để kiểm tra một access token có còn valid hay không, có expired chưa, có bị revoke hay chưa, có phải do Authorization Server của chúng ta issue hay không, chúng ta sẽ sử dụng endpoint token introspection của Authorization Server để làm điều này.

Với Authorization Server được implement sử dụng Spring Authorization Server, các bạn có thể sử dụng endpoint token introspection là POST request http://localhost:8080/oauth2/introspect với request body có chứa parameter token với value là access token mình chúng ta muốn kiểm tra, client_id và client_secret để authenticate request.

Giả sử bây giờ, các bạn lấy access token của một RegisteredClient được khai báo trong Authorization Server:

sau đó request tới endpoint token introspection, các bạn sẽ thấy kết quả như sau:

Add Comment