Select Page

Running Xero NetStandard oAuth2 Sample API runs into error:

Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET https://localhost:5000/home/signup  
Microsoft.AspNetCore.Routing.EndpointMiddleware:Information: Executing endpoint 'XeroOAuth2Sample.Controllers.HomeController.SignUp (XeroOAuth2Sample)'
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {action = "SignUp", controller = "Home"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult SignUp() on controller XeroOAuth2Sample.Controllers.HomeController (XeroOAuth2Sample).
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler:Information: XeroSignUp was not authenticated. Failure message: Not authenticated
Microsoft.AspNetCore.Authorization.DefaultAuthorizationService:Information: Authorization failed.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
Microsoft.AspNetCore.Mvc.ChallengeResult:Information: Executing ChallengeResult with authentication schemes (XeroSignUp).
Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler:Information: AuthenticationScheme: XeroSignUp was challenged.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action XeroOAuth2Sample.Controllers.HomeController.SignUp (XeroOAuth2Sample) in 29.5462ms
Microsoft.AspNetCore.Routing.EndpointMiddleware:Information: Executed endpoint 'XeroOAuth2Sample.Controllers.HomeController.SignUp (XeroOAuth2Sample)'
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 38.9997ms 302 

Turns out the issue is with return URL must be specified as :

Change

http://localhost:5000/

To:

https://localhost:5000/signup-oidc

And Enable HTTPS (SSL) in project (optional) launchSettings.json

{
  "profiles": {
    "XeroOAuth2Sample": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}