You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Authorization Server搭配Angular应用使用oidc-client.ts时出现oauth2/authorize 404错误的问题求助

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 11:14:30