This is a sample C# application to authenticate to Azure Active Directory and the Power BI REST API and query for information about existing workspaces. The application is a simple console application which makes uses of native .NET libraries as well as the Microsoft Identity Model Client library for authenticating to Azure Active Directory.
This application is only a very basic sample with minimal functionality and not intended for any sort of production use. The basic concepts for authentication, querying the API, and parsing the resposne could be taken and turned into a much more robust application.
For more information, see my blog post here: https://blog.jpries.com/2020/01/03/getting-started-with-the-power-bi-api-querying-the-power-bi-rest-api-directly-with-c/