public async Task <string> GetTokenUsingCertificateAsync(string authority, string resource, string scope) { var authContext = new AuthenticationContext(authority); var certificate = _certificateService.FindCertificateByThhumbprint(_appCertificateThumbprint, _certificateStoreLocation, _certificateStoreName); IClientAssertionCertificate certificateAssertion = new ClientAssertionCertificate(_azureAdClientId, certificate); var authResult = await authContext.AcquireTokenAsync(resource, certificateAssertion); return(authResult.AccessToken); }