---
title: Spring Security Oauth2.0调用check_token接口报错401 Unauthorized的解决方法
date: 2019-03-05 09:28:29
categories: Spring Security
tags:
- 报错
- spring
- unauthorized
- 接口
- security
- oauth2.0
- 401
- permitAll
- check_token
- AuthorizationServerSecurityConfigurer
- checkTokenAccess
- isAuthenticated
---
Spring Security Oauth2.0里帮我们封装了check_token接口,但是调用时报错
"status": 401,
"error": "Unauthorized",
"message": "Unauthorized",
百度google了半天,发现竟没有一个能解决问题的,卡在这个地方很久,最终在spring官网上找到了问题所在。特此记录,希望大家少走弯路。
原因是AuthorizationServerSecurityConfigurer的配置里checkTokenAccess的参数有问题。将checkTokenAccess("isAuthenticated()")改为.checkTokenAccess("permitAll()")即可。
Spring Oauth2.0官网:http://projects.spring.io/spring-security-oauth/docs/oauth2.html