skip to Main Content

I have a project that I created with the ASP.NET with Angular Visual Studio template with the individual accounts authentication type.

I then added Google authentication by following the steps outlined here.

https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-6.0

However, when I try and register, I get a error in the console stating

Error: Cannot match any routes. URL Segment: ‘signin-google’.

I tried following the exact same steps but with asp.net core web app using razor pages instead of angular, and it works properly. Is there something that I am missing with Angular?

Thanks for any suggestions

2

Answers


  1. Chosen as BEST ANSWER

    I managed to fix my problem. Angular was taking over the routing, when asp.net Identity should have been taking over. I fixed it, by changing the redirect URL for google by adding this line "googleOptions.CallbackPath = new PathString("/Identity/signin-google");" to my Program.cs file.


  2. You need to tell angular to exclude that route and forward it to the backend, by adding it in proxy.conf.js:

    const PROXY_CONFIG = [
      {
        context: [
          "/weatherforecast",
          "/_configuration",
          "/.well-known",
          "/Identity",
          "/connect",
          "/ApplyDatabaseMigrations",
          "/_framework",
          "/signin-google", //           <---- Right here
        ],
        target: target,
        secure: false,
        headers: {
          Connection: 'Keep-Alive'
        }
      }
    ]
    

    NOTE: The full path in the default .NET Angular template is ClientAppproxy.conf.js

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search