GDAP API: Authentication
Introduction
This article is describing our current GDAP API endpoint parameters, payloads and which call methods to use for specific tasks, and how to combine these workflows in C# implementation for Authentication flow.
In this article:
Rescource Links
Swagger UI - https://gdapauthservice.azurewebsites.net/api/swagger/ui
Base URL: https://gdapauthservice.azurewebsites.net/api/
Parameters
Url: {baseurl}AuthService
Method: POST
Parameters
| Key | Value | Description |
| helmuts.reinis@appxite.com | Your AAD email address here | |
| password | 01vh29............oh7n97an | Your password |
Example
POST - https://gdapauthservice.azurewebsites.net/api/Auth?username=helmuts.reinis@appxite.com&password=01vh29............oh7n97an
JSON Response 1 (If the password is correct) :
{
"access_token": "eyJ0eXAiOiJ.........qV0MC-65y8iO6eeRx7w"
}
JSON Response 2 (If provided incorrect):
nullResponse type will default to - 401 (Unauthorized)
C# Method Example:
public async Task<string> GetBearerToken(string baseUrl, string Username, string Password)
{
string uri = $"{baseUrl}AuthService?username={Username}&password={Password}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = 0;
request.Expect = "application/json";
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
return await reader.ReadToEndAsync();
}
}
Calling this method from code:
var MyAccessToken = await loginAPI.GetBearerToken(CurrentBaseUrl, tb_Username.Text, tb_Password.Text);
Summary
The GDAP API authentication endpoint uses a POST method at the base URL https://gdapauthservice.azurewebsites.net/api/AuthService with email and password parameters. Send authentication credentials via POST request to receive an access_token in JSON format if credentials are correct, or a null response with 401 Unauthorized status if credentials are incorrect. The C# implementation example demonstrates creating an HttpWebRequest with POST method, setting content type to application/json, and reading the response asynchronously to retrieve the bearer token. Complete API documentation is available through the Swagger UI at https://gdapauthservice.azurewebsites.net/api/swagger/ui for additional endpoint details and testing capabilities.
Add comment
Please sign in to leave a comment.