Spring Authorization Server搭配Angular应用使用oidc-client.ts时出现oauth2/authorize 404错误的问题求助
各位好!我最近在搭建Spring Authorization Server,想配合Angular前端用oidc-client.ts实现认证授权,但遇到了个棘手的问题——发起授权请求时,/oauth2/authorize接口返回404错误,折腾好久都没解决,想请大家帮忙看看哪里出问题了!
先贴一下我的相关配置:
build.gradle 依赖配置
dependencies { implementation("org.springframework.boot:spring-boot-starter-oauth2-authorization-server") implementation("org.springframework.boot:spring-boot-starter-web") }
客户端注册配置
@Configuration public class Clients { @Bean public RegisteredClientRepository registeredClientRepository() { RegisteredClient oidcClient = RegisteredClient.withId(UUID.randomUUID().toString()) .clientId("school-staff") .clientSecret("school-staff") .authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE) .authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN) .redirectUris( redirectUri-> { redirectUri.add("http://localhost:4200/"); redirectUri.add("(原代码内容截断)"); }) // 其余配置省略 .build(); return new InMemoryRegisteredClientRepository(oidcClient); } }
目前的情况是,Angular端通过oidc-client.ts发起授权请求时,目标地址是/oauth2/authorize,但服务器返回404。我已经确认前端的redirectUri和后端配置的一致,也检查了依赖是否正确引入,但还是找不到问题所在。有没有朋友遇到过类似的情况,或者能给我一些排查方向?
备注:内容来源于stack exchange,提问作者San Jaisy
相关产品推荐
相关产品推荐

