Use the Powell Governance API within ASP.NET with C#

We are thrilled to share with you that Powell Teams is now Powell Governance, marking our expanded focus on Microsoft 365!

Powell_Governance_V1 1.png

Expect documentation to be reflect this change in the coming days. For more information, please have a look at this article.

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

  1. Setup 

Authentication flow in the given project is based on the OAuth 2.0 authorization code flowhttps://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: 

 blobid0.png

 

Once the app is created in Azure AD, locate the launchsettings.json file in the project to update the ClientSecret and ClientId keys. 

blobid1.png

blobid2.png

         

       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.  

blobid3.png

blobid4.png

 

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. 

blobid5.png

 

 

Call the API 

Once authenticated, you will be able to call the Powell Governance API endpoints with classic .Net code, such as: 

blobid6.png

 

Note the SetHeaders method that is mandatory in order to pass the authentication token in the Authorization header to the Public API: 

blobid8.png

 

Was this article helpful?
0 out of 0 found this helpful