Http Client Post Request to get Oauth2 Token Using c#
string tenentID = "YOUR_TENENT_ID";
string clientID = "CLIENT_ID";
string clientSecret = "YOUR_CLIENT_SECRET";
HttpClient Rclient = new HttpClient();
var Rcontent = new StringContent("grant_type=client_credentials&client_id=clientID&client_secret=clientSecret", Encoding.UTF8, "application/x-www-form-urlencoded");
var result = await Rclient.PostAsync("https://login.microsoftonline.com/tenentID/oauth2/token", Rcontent);
string resultContent = await result.Content.ReadAsStringAsync();
Comments
Post a Comment