【问题标题】:Sorry, there was an error : invalid_request Missing openid scope IdentityServer4抱歉,出现错误:invalid_request Missing openid scope IdentityServer4
【发布时间】:2021-02-11 00:46:52
【问题描述】:

我正在尝试通过 IdentityServe 授权一个反应项目。

Sorry, there was an error : invalid_request
Missing openid scope
Request Id: 0HM6DDV35HLDE:00000001

告诉我可能是什么原因?看来网址是正确的。最有可能的原因在于配置参数。

配置:

public static IEnumerable<Client> Clients =>new List<Client>
    {
       new Client
         {
            ClientId = "js_oidc",
            ClientName = "Javascript Client",
            AllowedGrantTypes = GrantTypes.Implicit,
            AllowAccessTokensViaBrowser = true,
        
            AbsoluteRefreshTokenLifetime = 200,
            IdentityTokenLifetime = 15,
            AccessTokenLifetime = 100,
            AuthorizationCodeLifetime = 15,
            SlidingRefreshTokenLifetime = 120,
        
            RedirectUris =
            {
                "http://localhost:3000/callback.html",
                "http://localhost:3000/silent.html"
            },
            PostLogoutRedirectUris = { "http://localhost:3000/index.html" },
            AllowedCorsOrigins = { "http://localhost:3000" },
        
            AllowedScopes =
            {
                IdentityServerConstants.StandardScopes.OpenId,
                IdentityServerConstants.StandardScopes.Profile,
                IdentityServerConstants.StandardScopes.Email,
                "api1"
            }
            }
        };

授权服务:

    constructor() {
    const settings = {
        authority: "http://localhost:5001/",
        client_id: "js_oidc",
        redirect_uri: "http://localhost:3000/callback.html",
        silent_redirect_uri: "http://localhost:3000/silent.html",
        post_logout_redirect_uri: "http://localhost:3000/index.html",
        scope: "api1"
    };
    this.userManager = new UserManager(settings);
  }
 

【问题讨论】:

    标签: reactjs identityserver4


    【解决方案1】:

    你必须要求

    范围:“openid api1”

    在您的客户端中,因为在使用 openid 连接时 openid 是必需的范围。

    【讨论】:

    • 谢谢,成功了!现在授权后重定向不起作用。
    • 您是否在 IdentityServer 客户端定义中注册了准确的 URL?
    • AllowedCorsOrigins = { "http://localhost:3000" }, - 这个,否则需要在某个地方注册。添加了 Cors app.UseCors(options =&gt; options.WithOrigins("http://localhost:3000", "https://localhost:3000").AllowAnyMethod().AllowAnyHeader());
    • e = 错误:在 e.t [as readSigninResponseState] (localhost:3000/oidc-client.min.js:1:64722) 在 e.t [as processSigninRespons 处没有响应状态
    【解决方案2】:
     <script src="oidc-client.min.js"></script>
        <script>
            new Oidc.UserManager({ response_mode: "query" }).signinRedirectCallback().then(function () {
                window.location = "index.html";
            }).catch(function (e) {
                console.error(e);
            });
        </script>
    

    【讨论】:

      【解决方案3】:
      callback.html:21 Error: No state in response
          at e.t [as readSigninResponseState] (oidc-client.min.js:1)
          at e.t [as processSigninResponse] (oidc-client.min.js:1)
          at e.t [as _signinEnd] (oidc-client.min.js:47)
          at e.t [as signinRedirectCallback] (oidc-client.min.js:47)
          at callback.html:18
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-16
        • 1970-01-01
        • 2014-05-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多