Spring OAUTH2 - Access token expiry time

前端 未结 2 1026
后悔当初
后悔当初 2021-01-13 09:53

Is it possible to update/reset the expiry time of an access token programatically? If yes, which class/filter would be the best place to do it so that expiry time can be upd

2条回答
  •  盖世英雄少女心
    2021-01-13 10:08

    You can set the expiry time of an access token during client configuration. Changing values here will be updated in the jdbc token store.

    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
            clients.jdbc(dataSource)                        
                    .withClient("my-client-with-password")
                    .authorizedGrantTypes("password")
                    .authorities("ROLE_CLIENT") 
                    .scopes("read")
                    .resourceIds("oauth2-resource")
                    .accessTokenValiditySeconds(30);
    

    For this you have to delete the the existing client details from the database. Next time a token call is made, these client details will be added into the database, along with your updated validity time.

提交回复
热议问题