Open Closed

API Fails after Authenticated #1682


User avatar
0
damien.heasman created
  • ABP Framework version: v4.4.0
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Yes
  • Exception message and stack trace: System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
  • Steps to reproduce the issue:"

Hi. I’m really having some issues with deploying the ABP API project into Azure. I have spent many days going through all the different Settings, each of your related Support articles and your Tutorial on deploying to Azure. The current Solution I have deployed is just the Startup Template code with no Code changes. The solution is an MVC Tiered project and the only reason it is Tiered is because we are building a Xamarin Mobile App which we wish to use the separated Identity Server and Web API projects.

After deploying the API project to Azure the API works fine when using Swagger and I get a successful result when I’m not Authenticated. For example if I load the API project and Test the /api/abp/api-definition/ without authentication it works. As soon as I Authenticate with the Identity Server via the Swagger Authorize Dialog and I retry the same API Test (/api/abp/api-definition/) I get a 500 Error.

When looking at the API Logs I’m getting the following Exception:
2021-08-09 08:57:39.921 +00:00 [INF] Request finished HTTP/1.1 GET [https://app-civtraccore-api-test-001.azurewebsites.net/abp/Swashbuckle/SetCsrfCookie](https://app-civtraccore-api-test-001.azurewebsites.net/abp/Swashbuckle/SetCsrfCookie) \- \- \- 500 \- \- 11\.9688ms
2021-08-09 08:57:40.344 +00:00 [INF] Request starting HTTP/1.1 GET [https://app-civtraccore-api-test-001.azurewebsites.net/api/abp/application-configuration](https://app-civtraccore-api-test-001.azurewebsites.net/api/abp/application-configuration) \- \-
2021-08-09 08:57:40.346 +00:00 [ERR] Exception occurred while processing message.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
   at Microsoft.IdentityModel.Protocols.ConfigurationManager\`1.GetConfigurationAsync(CancellationToken cancel)
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
2021-08-09 08:57:40.346 +00:00 [ERR] An unhandled exception has occurred while executing the request.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
   at Microsoft.IdentityModel.Protocols.ConfigurationManager\`1.GetConfigurationAsync(CancellationToken cancel)
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationHandler\`1.AuthenticateAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft\.AspNetCore\.Diagnostics\.ExceptionHandlerMiddleware\.\<Invoke\>g\_\_Awaited\|6\_0\(ExceptionHandlerMiddleware middleware\, HttpContext context\, Task task\)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
   at Microsoft\.AspNetCore\.Diagnostics\.ExceptionHandlerMiddleware\.\<Invoke\>g\_\_Awaited\|6\_0\(ExceptionHandlerMiddleware middleware\, HttpContext context\, Task task\)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c\_\_DisplayClass6\_1.<\<UseMiddlewareInterface>b\_\_1>d.MoveNext()

When checking in Google Dev Tools I get the following

I have changed the AppSettings file in both API and Identity projects based on my Azure URLs and I have also changed the Identity Server settings via the Web UI. I'm happy to share all my Settings if that helps.


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.

    Is your IDS working properly?

    IdentityModelEventSource.ShowPII = true; //To show detail of error and see the problem
    
    Error 403 - Forbidden

    https://app-civtraccore-api-test-001.azurewebsites.net/.well-known/openid-configuration

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    It's probably your Identityserver is not running on https or not redirecting to https. Make sure running IdentityServer on https.

  • User Avatar
    0
    damien.heasman created

    I have resolved the issue.

    The issue is being caused by an Azure Access Restriction (i.e. Azure Web App Firewall) that was applied to both the API and Identity Server web apps. We had an Access Restriction on the Sites so that they could only be accessed from our corporate network. It's only because I noticed in maliming posts that there was a 403 Forbidden Error that I decided to remove the Access Restriction to help with resolving this Support Issue. Now I just need to figure out what Firewall Rule is required to let Identity Server work.

    Thanks maliming and gterdem for your help

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07