小编Oka*_*kan的帖子

观众是无效的错误

我有3个项目1- Javascript SPA 2- Web API项目,3-带有EF Core的IdentityServer

我开始调试API和Identity Server并成功获取jwt令牌但是,当我尝试从具有Authorize Attribute的API方法获取值时,我收到错误:

WWW-Authenticate ?Bearer error="invalid_token", error_description="The audience is invalid"
Run Code Online (Sandbox Code Playgroud)

我在auth选项中找不到任何关于观众的属性.这是我在API项目中的配置

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
        {
            ApiSecret="secret",
            Authority = "http://localhost:5000",
            ApiName="fso.Api",
            RequireHttpsMetadata = false,
        });
Run Code Online (Sandbox Code Playgroud)

我的Config.cs文件在Identity中

 public class Config
{        
    public static IEnumerable<ApiResource> GetApiResources()
    {
        return new List<ApiResource>
        {                
            new ApiResource()
            {
                Name = "fso.Api",                    
                DisplayName = "feasion API",
                Scopes =
                {
                    new Scope("api1"),
                    new Scope(StandardScopes.OfflineAccess)
                },
                UserClaims =
                {
                    JwtClaimTypes.Subject,
                    JwtClaimTypes.EmailVerified,
                    JwtClaimTypes.Email,
                    JwtClaimTypes.Name, 
                    JwtClaimTypes.FamilyName,
                    JwtClaimTypes.PhoneNumber,
                    JwtClaimTypes.PhoneNumberVerified,
                    JwtClaimTypes.PreferredUserName,
                    JwtClaimTypes.Profile, 
                    JwtClaimTypes.Picture, 
                    JwtClaimTypes.Locale, 
                    JwtClaimTypes.IdentityProvider,
                    JwtClaimTypes.BirthDate, 
                    JwtClaimTypes.AuthenticationTime
                } …
Run Code Online (Sandbox Code Playgroud)

jwt identityserver4

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

identityserver4 ×1

jwt ×1