Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
/oauth/authorize未映射到端点且不工作-Spring引导Oauth2_Spring_Spring Boot_Oauth_Oauth2_Spring Oauth2 - Fatal编程技术网

/oauth/authorize未映射到端点且不工作-Spring引导Oauth2

/oauth/authorize未映射到端点且不工作-Spring引导Oauth2,spring,spring-boot,oauth,oauth2,spring-oauth2,Spring,Spring Boot,Oauth,Oauth2,Spring Oauth2,我正在尝试执行一个简单的spring boot+oauth2应用程序,但我面临的问题是/oauth/authorize与oauth2服务器端点不匹配。该端点甚至没有列在可用API列表中 我的代码: package.com.example; 导入java.security.Principal; 导入org.springframework.beans.factory.annotation.Autowired; 导入org.springframework.boot.SpringApplication

我正在尝试执行一个简单的spring boot+oauth2应用程序,但我面临的问题是/oauth/authorize与oauth2服务器端点不匹配。该端点甚至没有列在可用API列表中

我的代码:

package.com.example;
导入java.security.Principal;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.boot.SpringApplication;
导入org.springframework.boot.autoconfigure.springboot应用程序;
导入org.springframework.context.annotation.Configuration;
导入org.springframework.security.authentication.AuthenticationManager;
导入org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
导入org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
导入org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
导入org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
导入org.springframework.security.oauth2.config.annotation.web.configurers.authorizationServerEndpointsConfiger;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RestController;
导入org.springframework.web.servlet.config.annotation.WebMVCConfigureAdapter;
@SpringBoot应用程序
@RestController
@EnableResourceServer
公共类DemoApplication扩展WebMVCConfigureAdapter{
公共静态void main(字符串[]args){
run(DemoApplication.class,args);
}
@配置
@EnableAuthorizationServer
受保护的静态类OAuth2Config扩展了AuthorizationServerConfigurerAdapter{
@自动连线
私人AuthenticationManager AuthenticationManager;
@凌驾
public void configure(AuthorizationServerEndpointsConfigurer端点)引发异常{
endpoints.authenticationManager(authenticationManager);
}
@凌驾
公共无效配置(ClientDetailsServiceConfigurer客户端)引发异常{
clients.inMemory().withClient(“foo”).secret(“foosecret”)
.authorizedGrantTypes(“授权代码”、“刷新令牌”、“密码”)。作用域(“openid”);
}
}
@请求映射(“/user”)
公共主要用户(主要用户){
返回用户;
}

}
您正在使用
@EnableResourceServer
。您需要使用
@EnableAuthorizationServer


OAuth2术语中的资源服务器将是一个从授权服务器接受OAuth2令牌的服务。

您使用的是
@EnableResourceServer
。您需要使用
@EnableAuthorizationServer

OAuth2术语中的资源服务器将是一个从授权服务器接受OAuth2令牌的服务