设置 url 使用 spring security rest 在 grails 中刷新令牌 JWT

set url to refresh token JWT in grails using spring security rest

我正在使用 spring 安全休息。实际上要使用此 url 刷​​新令牌 im:/oauth/access_token?grant_type=refresh_token&refresh_token=token

但是我正在使用 api 休息,我想使用 /api/oauth 来刷新令牌而不是 /oauth.

我尝试在 urlMappings 中重定向,但未找到响应 404。

"/api/oauth"(redirect: '/oauth')

"/api/oauth"(redirect: '/oauth')

如您所见,该映射将不起作用,但无论如何都没有充分的理由使用重定向。该插件提供了这样的映射:

"/oauth/access_token"(controller: 'restOauth', action: 'accessToken')

(参见 https://github.com/alvarosanchez/grails-spring-security-rest/blob/d5940921b4aea466a961957e0599321d01e4c6de/spring-security-rest/grails-app/controllers/grails/plugin/springsecurity/rest/RestOauthUrlMappings.groovy#L24

您可以将任何 url 您喜欢的内容映射到该控制器。你可以这样做...

"/api/oauth"(controller: 'restOauth', action: 'accessToken')