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

使用ASP.NET Core集成Autodesk Forge Authentication v2遇请求错误求助

解决ASP.NET Core集成Forge Authentication V2时的code_verifier缺失问题

问题原因

Forge Authentication V2强制要求使用PKCE(授权码流程的增强安全机制),你的ASP.NET Core应用当前的OpenID Connect配置未启用PKCE相关设置,导致回调时缺少code_verifier参数,触发invalid_request错误。

修复步骤

  • 修改OpenID Connect服务配置
    在Program.cs(或Startup.cs)的认证服务配置中,添加PKCE相关设置:

    builder.Services.AddAuthentication(options =>
    {
        options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
    })
    .AddCookie()
    .AddOpenIdConnect(options =>
    {
        options.ClientId = "你的Client Id";
        options.ClientSecret = "你的Client Secret";
        options.Authority = "https://developer.api.autodesk.com/authentication/v2";
        options.ResponseType = "code";
        // 启用PKCE
        options.UsePkce = true;
        // 配置回调路径,需与Forge应用中设置的一致
        options.CallbackPath = "/signin-oidc";
        // 按需添加所需的Scope
        options.Scope.Add("openid");
        options.Scope.Add("profile");
        // 其他必要配置...
    });
    
  • 确认Forge应用配置
    确保在Forge开发者平台创建的Web Server应用中,回调URL与ASP.NET Core应用的CallbackPath完全匹配(例如https://localhost:5001/signin-oidc)。

  • 重新运行应用
    重启ASP.NET Core应用,再次访问隐私页面完成登录流程,错误应已解决。

错误原文:
OpenIdConnectProtocolException: Message contains error: 'invalid_request', error_description: 'The request is missing a required parameter 'code_verifier'.', error_uri: 'error_uri is null'.

内容的提问来源于stack exchange,提问作者Mostafa abdo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 01:57:11