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.

Resource Links

Swagger UI - https://gdapauthservice.azurewebsites.net/api/swagger/ui

Base URL: https://gdapauthservice.azurewebsites.net/api/

 

Url: {baseurl}AuthService
Method: POST

Parameters

Key Value Description
email 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):

null

Response 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);

Was this article helpful?

0 out of 0 found this helpful

Add comment

Please sign in to leave a comment.