Archive for August, 2018
Configure Swagger to authenticate against Azure AD
If you are building a Web API secured by Azure AD you will need to authenticate to test the API. Configuring OAuth 2 in Swagger allows you to authenticate using the Swagger UI and test the API with the necessary authentication headers.
The steps to configure this are:
- Create a Web API project
- Register an Azure AD (AAD) app for the Web API
- Update the Web API project to use Azure AD authentication
- Register an AAD app for the Swagger web site
- Grant permissions for the Swagger AAD app to access the Web API AAD app
- Generate a Client Secret for the Swagger AAD app
- Enable OAuth2 implicit flow on the Swagger AAD app
- Add Swagger to the Web API