2017-04-19 8 views
0

ASP.NET Core Webアプリケーションは、ローカルで実行およびデバッグするときに機能します。Work(Azure AD)を使用したASP.NETコアWebアプリケーションは、ローカルでデバッグを行いますが、Azureに公開した後は動作しません。

  • 私は組織認証を有効にし、公開時に適切なドメインを選択しました。リクエストを処理している間

    未処理の例外が発生しました:私は私はこのエラーを取得するのAzureに公開した後

  • 適切な応答URLを

を登録しました。 OpenIdConnectProtocolException:メッセージに「 'invalid_client'、error_description: 'AADSTS70002」というエラーが含まれています。リクエスト本体に' client_secret or client_assertion 'というパラメータが含まれている必要があります。 トレースID:640186d6-9a50-4fce-ae39-bbfc1caf2400 相関ID:622758b2-ca52-4bb0-9a98-e14d5a45cf80 タイムスタンプ:2017-04-19 16:36:32Z '、error_uri:' error_uriはnull 'です。

クライアントシークレットをAzureに保存する必要があると仮定しています。しかし、誰かが別の投稿で行うことができたのを見て、私はそれをApp Setting(無効なクライアントシークレットエラー)として追加したとき、secrets.jsonの値は機能しませんでした。とにかくAzure AppSettingsに "Authentication:AzureAd:ClientSecret"の値を入れても良いのかどうかは分かりません。

+0

はそれをしないのに役立ちますあなたがAzure AppSettingsに配置するとうまくいきますか? – Win

+0

AppSettingsに含まれている場合は、別のエラーが発生します。Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectProtocolException:メッセージにエラーがあります: 'invalid_client'、error_description: 'AADSTS70002:認証情報の検証中にエラーが発生しました。 AADSTS50012:無効なクライアントシークレットが提供されています。 –

+0

私の[GitHubリポジトリ](https://github.com/WinLwinOoNet/AspNetCoreAzureAD#azure-portal---app-registrations---step-1)でスクリーンショットを見て、あなたが見逃したステップを見てください。 – Win

答えて

0

どういうわけか、Azure Active Directory App Registrationに必要なAzure AD IDが混在していました。 2つのApp登録エントリがあり、ClientIDとTenentIDがローカルと一致しませんでした。だから私は、クライアントとTenentのIDをApp Registrationの項目の一つと同期させ、Client SecretがApp Settingsに入っていることを確認して、正しく動作しました。

この例はWin's GitHub repositoryで確認しましたが、今は一致しています。

0

これが誰にも役立つかどうかはわかりません。しかし、同様のエラーメッセージが表示されます。

OpenIdConnectProtocolException: Message contains error: 'invalid_client', error_description: 'error_description is null', error_uri: 'error_uri is null'. 
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler+<RedeemAuthorizationCodeAsync>d__22.MoveNext() 

私のためのソリューションは、トークンサービス

,new Client 
      { 
       ClientId = "Testclient", 
       ClientName = "client", 
       ClientSecrets = 
       { 
        new Secret("secret".Sha256()) 
       }, 
       //Hybrid is a mix between implicit and authorization flow 
       AllowedGrantTypes = GrantTypes.Hybrid, 

秘密を提供し、クライアントに秘密情報を提供することでした

app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
      { 
       //The name of the authentication configuration.. just incase we have multiple 
       AuthenticationScheme = "oidc", 
       //Represents where to store the identity information -> which points to the cookie middleware declared above 
       SignInScheme = "Cookies", 

       //where the token service reside -> system will configure itself by invoking the discovery endpoint for the token service 
       Authority = "http://localhost:5000", 
      RequireHttpsMetadata = false, 

      ClientId = "Testclient", 
      ClientSecret = "secret", 
      //hybrid flow -grant type 
      ResponseType = "code id_token", 

うまくいけば、これは誰か

関連する問題