Base solution for your next web application
Open Closed

IdentityServer issue on Azure #7710


User avatar
0
Ricavir created

Hi support team,

I need to integrate my app with Zapier. For that, I need Oauth v2 authentication... therefore, I activate IdentityServer on appsettings file. I can test it with console application "ConsoleApiClient" : it works.

I wanted to test on my azure appservice but application doesn't start at all : I'm getting an Internal Server Error

Can you please help me ?


12 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    You can follow the documentation to confirm the cause of the problem.

    https://docs.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-2.2

  • User Avatar
    0
    Ricavir created

    This doesn't help. I just enabled IdentityServer on appsettings file :

    "IdentityServer": {
        "IsEnabled": "true",
        "Authority": "https://------app-service-stagging.azurewebsites.net/",
        "ApiName": "default-api",
        "ApiSecret": "secret",
        "Clients": [
          {
            "ClientId": "client",
            "AllowedGrantTypes": [ "password" ],
            "ClientSecrets": [
              {
                "Value": "def2edf7-5d42-4edc-a84a"
              }
            ],
            "AllowedScopes": [ "default-api" ]
          }
        ]
      },
    

    The only difference between a running project on azure and the error described previously is just changing "IsEnabled" property to "true".

  • User Avatar
    0
    maliming created
    Support Team

    We have to see the application's log to determine the problem. Can't judge from the screenshot.

    You can try the solution in the article below to see the application's error log.

    https://scottsauber.com/2017/04/10/how-to-troubleshoot-an-error-occurred-while-starting-the-application-in-asp-net-core-on-iis/

  • User Avatar
    0
    Ricavir created

    Tks @maliming

    Here is the error log :

    Application startup exception: System.InvalidOperationException: Grant types list contains duplicate values at IdentityServer4.Models.Client.ValidateGrantTypes(IEnumerable`1 grantTypes) at Web.IdentityServer.IdentityServerConfig.GetClients(IConfigurationRoot configuration) in \IdentityServer\IdentityServerConfig.cs:line 39 at Web.IdentityServer.IdentityServerRegistrar.Register(IServiceCollection services, IConfigurationRoot configuration) in Core\IdentityServer\IdentityServerRegistrar.cs:line 13 at Web.Startup.Startup.ConfigureServices(IServiceCollection services) in Web.Host\Startup\Startup.cs:line 106 --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services) at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

    It is strange has I just defined "password" as grant type. I tried to change it by

    "AllowedGrantTypes": [ "hybrid", "client_credentials" ],

    But same error.

  • User Avatar
    0
    maliming created
    Support Team

    Sorry : )

    Do you also define the Identity Server configuration in other appsettings files? Such as: appsettings.Production.json

    If not, is it convenient to share your project code to: [email protected]?

  • User Avatar
    0
    Ricavir created

    Yes,

    I'm running my tests on Staging slot so the file used is appsettings.staging.json. As far as I deactivate IdentityServer property, the app runs again. It is not an issue with this file.

  • User Avatar
    0
    maliming created
    Support Team

    hi @ricavir

    Is it convenient to share your project code to: [email protected]?

  • User Avatar
    0
    Ricavir created

    Unfortunately, it is not allowed by our company rules.

    Has I said, IdentityServer activation works on my dev machine but not on Azure server...

    Have you tried to enable identityserver over your cloud servers ?

  • User Avatar
    0
    maliming created
    Support Team

    hi @ricavir I believe that your configuration has a conflict, please see the screenshot.

  • User Avatar
    0
    Ricavir created

    You are right ! I removed appsettings.json and appsettings.production.json and it is working now.

    Do you know why I had this behavior ? It's like a mix is being done between appsettings files !?

  • User Avatar
    0
    maliming created
    Support Team

    I also find it strange, but this is the behavior of Net Core.

  • User Avatar
    0
    Ricavir created

    Thank you