string tokenEndpoint = "https://<servername>/adfs/oauth2/token"; string clientId = "<clientid>"; string clientSecret = "<clientsecret>"; string scope = "https://localhost/exampleapi/readdata"; var client = new HttpClient(); // Obtain the token var tokenResponse = await client.PostAsync(tokenEndpoint, new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("client_id", clientId), new KeyValuePair<string, string>("client_secret", clientSecret), new KeyValuePair<string, string>("grant_type", "client_credentials"), new KeyValuePair<string, string>("scope", scope) }));