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)
-
1
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.
-
0
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
-
0
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
orApp:RootUrl
) in the appsettings. When you set the environment and run the DbMigrator, it will add the staging data from the appsettings.