新版本IdentityServer4踩坑

1.报错“Invalid request”

新版本已经将form-data方式改为x-www-form-urlencoded

 

2.报错“Invalid Request”

新版本范围定义发生了改变

public static IEnumerable<ApiResource> GetApiResources()
        {
            return new[]
            {
                new ApiResource("UserApi", "用户获取API")
                {
                    Scopes={"UserApi"}
                }
            };
        }

添加了红色部分,另外还需要在配置中定义

public static IEnumerable<ApiScope> ApiScopes =>
            new ApiScope[]
            {
                new ApiScope("UserApi")
            };

在ConfigureService 中定义

.AddInMemoryApiScopes(ClientInitConfig.ApiScopes);  //定义范围

 

posted @ 2020-12-25 23:38  RookieCoderAdu  阅读(235)  评论(0编辑  收藏  举报