Microsoft graph api 通过Microsoft.Identity.Web请求图形权限时出错

Microsoft graph api 通过Microsoft.Identity.Web请求图形权限时出错,microsoft-graph-api,microsoft-identity-platform,Microsoft Graph Api,Microsoft Identity Platform,我在我的应用程序中得到以下基于的错误堆栈。我正在尝试登录并获取User.ReadBasic.All graph权限的令牌。我检查了AcquireTokenByAuthorizationCode中的所有参数,结果都很好(没有空值)。应用程序是使用.net core 3.1的MVC web应用程序 堆栈: NullReferenceException:对象引用未设置为对象的实例。 Microsoft.Identity.Client.Internal.ClientCredentialWrapper.g

我在我的应用程序中得到以下基于的错误堆栈。我正在尝试登录并获取User.ReadBasic.All graph权限的令牌。我检查了AcquireTokenByAuthorizationCode中的所有参数,结果都很好(没有空值)。应用程序是使用.net core 3.1的MVC web应用程序

堆栈:

NullReferenceException:对象引用未设置为对象的实例。 Microsoft.Identity.Client.Internal.ClientCredentialWrapper.get_指纹() Microsoft.Identity.Client.Internal.JsonWebToken+JWTHeaderWithCertificate..ctor(客户端凭据包装器凭据,bool sendCertificate) Microsoft.Identity.Client.Internal.JsonWebToken.EncodeHeaderToJson(客户端凭据包装器凭据,bool sendCertificate) Microsoft.Identity.Client.Internal.JsonWebToken.Encode(ClientCredentialWrapper凭证,bool sendCertificate) Microsoft.Identity.Client.Internal.JsonWebToken.Sign(ClientCredentialWrapper凭证,bool sendCertificate) Microsoft.Identity.Client.Internal.Requests.ClientCredentialHelper.CreateClientCredentialBodyParameters(ICoreLogger logger、ICryptographyManager cryptographyManager、ClientCredentialWrapper clientCredential、string clientId、AuthorityEndpoints endpoints、bool sendX5C) Microsoft.Identity.Client.OAuth2.TokenClient.SendTokenRequestAsync(IDictionary additionalBodyParameters,string scopeOverride,string tokenEndpointOverride,CancellationToken CancellationToken) Microsoft.Identity.Client.Internal.Requests.RequestBase.SendTokenRequestAsync(字符串tokenEndpoint,IDictionary additionalBodyParameters,CancellationToken CancellationToken) Microsoft.Identity.Client.Internal.Requests.SecretentialAuthCodeRequest.ExecuteAsync(CancellationToken CancellationToken) Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken CancellationToken) Microsoft.Identity.Client.ApiConfig.Executors.SecretentialClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters、AcquireTokenByAuthorizationCodeParameters authorizationCodeParameters、CancellationTokenCancellationToken) TokenAcquisition.cs中的Microsoft.Identity.Web.TokenAcquisition.AddAccountToCacheFromAuthorizationCodeAsync(AuthorizationCodeReceivedContext上下文,IEnumerable作用域) + var结果=等待应用程序 WebAppServiceCollectionExtensions.cs中的Microsoft.Identity.Web.WebAppServiceCollectionExtensions+c_uDisplayClass2_1+d.MoveNext() + await tokenAcquisition.AddAccountToCacheFromAuthorizationCodeAsync(上下文,options.Scope)。ConfigureAwait(false); Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.RunAuthorizationCodeReceivedEventAsync(OpenIdConnectMessage authorizationResponse,ClaimsPrincipal用户,AuthenticationProperties属性,JwtSecurityToken jwt) Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandlerEmoteAuthenticationAsync()

代码: 来自TokenAcquisition.cs-第127行

                // Do not share the access token with ASP.NET Core otherwise ASP.NET will cache it and will not send the OAuth 2.0 request in
                // case a further call to AcquireTokenByAuthorizationCodeAsync in the future is required for incremental consent (getting a code requesting more scopes)
                // Share the ID Token though
                var result = await application
                    .AcquireTokenByAuthorizationCode(scopes.Except(_scopesRequestedByMsal), context.ProtocolMessage.Code)
                    .ExecuteAsync()
                    .ConfigureAwait(false);
                context.HandleCodeRedemption(null, result.IdToken);

已解决:由于此处讨论的错误配置,这原来是一个空的客户端机密值: