3using System.Threading.Tasks;
 
    4using IdentityModel.Client;
 
   23        private readonly 
string _clientId;
 
   25        private readonly 
string _secret;
 
   27        private readonly 
string _authEndpoint;
 
   29        private readonly 
string _scope;
 
   43            _authEndpoint = authEndpoint;
 
 
   51            var client = 
new HttpClient();
 
   52            var response = await client.RequestClientCredentialsTokenAsync(
new ClientCredentialsTokenRequest
 
   54                Address = _authEndpoint,
 
   56                ClientSecret = _secret,
 
   60            if (String.IsNullOrWhiteSpace(response.AccessToken))
 
 
 
An AccessToken storing Bearer authentication information for requests made to the server,...
 
Machine-to-Machene authorization workflow.
 
BearerAuthenticationToken AccessToken
If Authorize() returns true then this property contains a new access token.
 
async Task< bool > Authorize()
Sets AccessToken and returns true if authorization was successful. Otherwise, it sets ErrorDescriptio...
 
MachineToMachineAuth(string clientId, string secret, string scope, string authEndpoint)
Machine-to-machine authorization workflow.
 
string ErrorDescription
If Authorize() returns false then this property contains an error message.