Spring Boot- Invalid access token error

社会主义新天地 提交于 2019-12-05 22:08:33

make sure that in your AuthServerOAuth2Config security.allowFormAuthenticationForClients().checkTokenAccess("permitAll()");

@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {     
    security.allowFormAuthenticationForClients().checkTokenAccess("permitAll()");       
}

and start generating some tokens by making POST requests to your server at URL:localhost:yourport/oauth/token

for example:

http://localhost:8085/oauth/token?client_secret=secret&client_id=web&grant_type=password&username=kalaiselvan&password=kalaiselvan

it will return token

 {
   "access_token": "8b816685-b7da-4996-a3e2-ff18b4538a2b",
   "token_type": "bearer",
   "refresh_token": "f458c09b-f739-4488-be0f-2b0e3c5a62d1",
   "expires_in": 637,
   "scope": "read"
 }

copy the access_token from the response data and make new POST request http://localhost:8085/account

I hope it will be helpful to you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!