If you want to implement your custom .Net Application targeting our public API, you can use the starter project attached. You can find the ZIP file at the end of the article.
Authentication
- Setup
Authentication flow in the given project is based on the OAuth 2.0 authorization code flow: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
For this authentication flow to work, you will need to create an Azure AD application to authenticate your requests, with the following delegated scopes:
- Directory.AccessAsUser.All
- Group.ReadWrite.All
- Notes.Read.All
- Notes.ReadWrite.All
- Sites.Read.All
- User.Invite.All
- User.Read
- User.Read.All
To do so, refer to the following documentation: https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis
Don’t forget to configure the app with the redirect URLs based on your web application url:
Once the app is created in Azure AD, locate the launchsettings.json file in the project to update the ClientSecret and ClientId keys.
2. How it works in code
Once everything is configured, and the project is launched, the HomeController will redirect the user to the Azure AD login page.
Once the user logs in, the user will be redirected to the AuthorizationController, with a code to redeem the authentication. Then the AuthorizationController will redirect the user back to the HomeController.
Call the API
Once authenticated, you will be able to call the Powell Governance API endpoints with classic .Net code, such as:
Note the SetHeaders method that is mandatory in order to pass the authentication token in the Authorization header to the Public API: