This project is a .NET 8 console application that demonstrates how to get an access token from the ThoughtSpot REST API.
The application reads configuration settings from the GetAccessToken/appSettings.json file, including the ThoughtSpot cluster URL, username, and secret key. It then constructs an HTTP POST request to the ThoughtSpot authentication endpoint to retrieve an access token. The JSON response containing the access token is then printed to the console.
This project is self-contained. While it uses NuGet packages for configuration (Microsoft.Extensions.Configuration.Json and Microsoft.Extensions.Configuration.Binder), these are standard Microsoft libraries and no other third-party libraries are required.
To run this project and see it in action, follow these steps:
-
Prerequisites: Ensure you have the .NET 8 SDK installed on your machine.
-
Configure the application:
- Open the
GetAccessToken/appSettings.jsonfile. - Modify the values for
TsClusterBaseUrl,Username, andSecretto match your ThoughtSpot environment and credentials. - The
TsUserAgentcan be any string and is required by the API. - The
ValidityTimeInSecdetermines how long the retrieved access token will be valid (in seconds).
- Open the
-
Run from the command line:
- Open a terminal or command prompt.
- Navigate to the
GetAccessTokendirectory. - Run the following command:
dotnet run
After running the command, the application will make a request to the ThoughtSpot API. If successful, you will see the JSON response printed in the console, which includes the access token. If there is an error (e.g., incorrect credentials), an exception message will be displayed.