I have implemented an OAuth2 provider in ADFS 2012R2 that is being consumed in both a Xamarin application with a NodeJS server. I want to write automated tests against my NodeJS Rest Endpoints so I need to generate an access_token programmatically from ADFS. I have searched far and wide and can't seem to figure out how to get an access_token from ADFS 3.0 programmatically (2016 and above have more supported grant types that allow it). Anyone have any idea how to accomplish this?
I have tried this solution here: Does ADFS 2012 R2 support Auth2 Resource Owner Password Credentials flow with the endpoint of "https://myadfsserver/adfs/oauth2/token" with a grant_type=password, but that doesn't work as ADFS 2012R2 doesn't support that grant_type.
I have tried ADAL:
AuthenticationContext ac = new AuthenticationContext(AuthorizeUrl, false);
AuthenticationResult result;
try
{
result = await ac.AcquireTokenAsync(Resource, ClientId, new UserPasswordCredential("username", "password"));
}
but that fails with 3 different exceptions at once.
Any help would be great.