Use this when there is need to get token for user. This will be interactive though.
From PowerShell
Install-Module -Name MSAL.PS
restart powershell.
$authority = "https://login.microsoftonline.com/common"
#this is the security and compliance center endpoint
$resourceUrl = "https://database.windows.net/"
$clientId = "1950a258-227b-4e31-a9cf-717495945fc2" # known powershell client id
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
Get-MsalToken -ClientId $clientId -RedirectUri $redirectUri
$response.AccessToken | clip
From C# program
string clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" // known powershell client id
string aadTenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
string ResourceId = "https://database.windows.net/";
string AadInstance = "https://login.windows.net/{0}";
AuthenticationContext authenticationContext = new AuthenticationContext(string.Format(AadInstance, aadTenantId));
var user = new UserCredential("myalias");
AuthenticationResult authResult = authenticationContext.AcquireTokenAsync(ResourceId, clientId, user).Result
(Edit: client IDs and tenant ID removed from code example /cc AmolAgarwalSQL)