Open Closed

Not able to Authenticate through Swagger #1896


User avatar
0
mhassanin created

I am facing the same issue as Not able to Authenticate through Swagger of Custom Module API #1121

2021-09-24 14:29:24.431 +00:00 [ERR] Invalid redirect_uri: https://fwateer.azurewebsites.net/swagger/oauth2-redirect.html {"ClientId":"eInvoicing_Swagger","ClientName":"eInvoicing_Swagger","RedirectUri":null,"AllowedRedirectUris":["https://localhost:44318/swagger/oauth2-redirect.html"],"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":{"response_type":"code","client_id":"eInvoicing_Swagger","redirect_uri":"https://fwateer.azurewebsites.net/swagger/oauth2-redirect.html","scope":"eInvoicing","state":"RnJpIFNlcCAyNCAyMDIxIDE2OjI5OjE3IEdNVCswMjAwIChFYXN0ZXJuIEV1cm9wZWFuIFN0YW5kYXJkIFRpbWUp"},"$type":"AuthorizeRequestValidationLog"} 2021-09-24 14:29:24.447 +00:00 [ERR] Request validation failed


3 Answer(s)
  • User Avatar
    1
    gterdem created
    Senior .NET Developer

    2021-09-24 14:29:24.431 +00:00 [ERR] Invalid redirect_uri: https://fwateer.azurewebsites.net/swagger/oauth2-redirect.html

    {"ClientId":"eInvoicing_Swagger","ClientName":"eInvoicing_Swagger","RedirectUri":null,"AllowedRedirectUris": ["https://localhost:44318/swagger/oauth2-redirect.html"]

    Apparently you have the dev environment redirect uri (https://localhost:44318/swagger/oauth2-redirect.html) and missing production redirect uri (https://fwateer.azurewebsites.net/swagger/oauth2-redirect.html) for the swagger client.

    Check your database (or from identity server UI) that your client with eInvoicing_Swagger ID has https://fwateer.azurewebsites.net/swagger/oauth2-redirect.html redirect Uri.

  • User Avatar
    0
    mhassanin created

    Thanks a lot for the quick response, I did insert a record in IdentityServerClientRedirectUris table withthe requiered info and it works, Is this is the right way to do it, I mean inserting a row in the table? or there a UI for the API.HOST porject to mange this?

    Thanks Mohamed Hassanin

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Use IdentityServer Management:

    Navigate to Administration ->Identity Server -> Clients Under Actions button, Edit -> Application Urls -> Callback

    Use DbMigrator with Different Environment

    Create an other environment like appsettings.staging.json that has staging client root url (Swagger:RootUrl or App:RootUrl) in the appsettings. When you set the environment and run the DbMigrator, it will add the staging data from the appsettings.

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