资源服务器返回错误“无效令牌”

问题描述 投票:0回答:1

我将密钥斗篷用作授权服务器。keycloak configuration

我对资源服务器的application.yml-> application.yml

ResourceServer代码

@SpringBootApplication
@RestController
@EnableResourceServer
@EnableWebSecurity
public class Demo1Application {

@GetMapping("/test")
public String demo1(){

    return "Test";
}
public static void main(String[] args) {
    SpringApplication.run(Demo1Application.class, args);
  } 

}

问题是,当我以curl -H“ Authorization:$ Token” http://localhost:8085/test的身份发送请求时,出现错误-无效的访问令牌。我不知道怎么了。

spring security oauth-2.0 keycloak
1个回答
1
投票

不使用授权: ?也许尝试:

curl -H "Authorization: Bearer $token" http://localhost:8085/test
© www.soinside.com 2019 - 2024. All rights reserved.