I am trying to add authentication to api call in Rest sharp version 108.0.2
error : 'authority' should be in Uri format Parameter name: authority
I have upgraded the Restsharp version from 106 to 108 , Then here previously we are using HttpClient but there are some deprecated interfaces in that so i am trying to use RestClient but here i am unable to get below authmechanism.
var response = HttpClient.CallAsync<string>(new HttpClientArgs
{
Uri = new Uri(uri),
Verb = HttpVerb.Put,
HttpAuthMechanism = HttpAuthMechanism.AzureAd,
AzureAdConfig = new AzureAdConfig()
{
ClientId = ClientID,
ClientSecret = ClientSecret,
ResourceId = ResourceID,
TenantId = TenantID
},
Body = JsonConvert.SerializeObject(body)
});
string Authority = String.Format(TenantID);
AuthenticationContext ac = new AuthenticationContext(Authority);
string resourceID = ResourceID;
string clientID = ClientID;
try
{
UserCredential uc = new UserCredential();
Task<AuthenticationResult> task = ac.AcquireTokenAsync(resourceID, clientID, uc);
task.Wait(10000);
AuthenticationResult result = task.Result;
string token = result.AccessToken;
return token;
}
catch (Exception ex)
{
if (ex.InnerException.Message.ToLower().Contains("interactive authorization"))
{
string token = "prompt";
return token;
}
return (ex.Message);
throw ex;
}