spring security oauth2 出现404

问题描述

spring security oauth2 构建简单的认证基于内存的,登录之后出现404问题。

clipboard.png

问题出现的环境背景及自己尝试过哪些方法

clipboard.png

clipboard.png

相关代码

@Configuration
@EnableAuthorizationServer
public class Configuretion extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private BCryptPasswordEncoder bCryptPasswordEncoder;

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients
                .inMemory()
                .withClient("client")
                .secret(bCryptPasswordEncoder.encode("secret"))
                .authorizedGrantTypes(" authorization_code")
                .scopes("app")
                .redirectUris("http://www.baidu.com");
    }
}


@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true)
public class WebSecurityConfigure extends WebSecurityConfigurerAdapter {

    @Bean
    public BCryptPasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("admin").password(passwordEncoder().encode("123456")).roles("ADMIN")
                .and()
                .withUser("user").password(passwordEncoder().encode("123456")).roles("USER");
    }
}
spring:
  application:
    name: oauth2-server
server:
  port: 8080

你期待的结果是什么?实际看到的错误信息又是什么?

地址栏访问http://localhost:8080/oauth/authorize?client_id=client&response_type=code
出现登录页面,输入admin 密码123456,就报404了,是什么原因

阅读 11.8k
4 个回答

请问您是什么原因引起,我的效果一模一样404 2020 03 27 在线等

新手上路,请多包涵
.authorizedGrantTypes(" authorization_code")

多了个空格会影响吗 你试试

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题