Open Closed

"Invalid redirect_uri" - RedirectAllowedUrls on Login page #1009


User avatar
0
Leonardo.Willrich created
  • ABP Framework version: v4.2.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

Hi, I have created a simple CRUD in the Blazor Commercial ABP.IO framework. I am trying to deploy to a IIS server and I am getting issue when clicking in Login link, it is returning Error 500. In the logs files, I could see:

2021-03-07 05:43:17.967 +00:00 [ERR] Invalid redirect_uri: https://avalancheocp.tvdinc.com/authentication/login-callback {"ClientId":"AvalancheOCP_Blazor","ClientName":"AvalancheOCP_Blazor","RedirectUri":null,"AllowedRedirectUris":["https://localhost:44307/authentication/login-callback"],"SubjectId":"anonymous","ResponseType":null,"ResponseMode":null,"GrantType":null,"RequestedScopes":"","State":null,"UiLocales":null,"Nonce":null,"AuthenticationContextReferenceClasses":null,"DisplayMode":null,"PromptMode":"","MaxAge":null,"LoginHint":null,"SessionId":null,"Raw":{"client_id":"AvalancheOCP_Blazor","redirect_uri":"https://avalancheocp.tvdinc.com/authentication/login-callback","response_type":"code","scope":"openid profile AvalancheOCP role email phone","state":"cf815de5d3414edc8f74d53c799f1a30","code_challenge":"krQ1k5KNh9_QFBaWHwRW-JR4wXFJMUTuzpgUYcSApHA","code_challenge_method":"S256","response_mode":"query"},"$type":"AuthorizeRequestValidationLog"}

I have already changed the appsettings.json as below, but, even restarting all IIS, it keeps showing https://localhost:44307. It seems to be hardcoded in some point.

appsettings.json:

"App": {
    "SelfUrl": "https://avalancheocp.host.tvdinc.com",
    "CorsOrigins": "https://*.tvdinc.com",
		"RedirectAllowedUrls": "https://avalancheocp.tvdinc.com"
  },

What would be wrong?


4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    https://avalancheocp.tvdinc.com/authentication/login-callback

    https://localhost:44307/authentication/login-callback

    You need to change the client's redirect_uri in the database table.

    The easy way:

    1. remove database( be careful, if you have real production data)
    2. Change RootUrl in file appsettings.json of .DbMigrator project. https://localhost:44307/ to https://avalancheocp.tvdinc.com/
    3. Rebuild the database
  • User Avatar
    0
    Leonardo.Willrich created

    Hi @maliming. Yes, I have seed the database in my local environment (develpment) with localhost:44307. And then I have just copied the same database to the test environement with a different url.

    @liangshiwei, is there a way to just run an update in the database? Do I have access to the table/field to be updated?

  • User Avatar
    2
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Try

    update IdentityServerClientRedirectUris set RedirectUri = 'https://avalancheocp.tvdinc.com/authentication/login-callback' where RedirectUri = 'https://localhost:44307/authentication/login-callback'

  • User Avatar
    0
    Leonardo.Willrich created

    Perfect, it is working fine.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11