我创建了一个在本地计算机上运行的服务。本地计算机安装了一些用于授权和获取访问令牌的证书。
所有这些事情以前都是在本地机器上发生的。
GetCertificateFromStore();
AuthenticationResult result = _authContext.AcquireTokenAsync(string ResourceId,ClientAssertionCertificate certificateCredential).Result;
if (result != null)
{
AccessToken = result.AccessToken;
return true;
}
return false;
现在我想将这个证书传递给一些web api,并将访问令牌从那里返回到本地计算机。我可以通过证书,但在web api方面,未找到显示私钥错误的通过证书。
// Below is the code I am using to call api for accessing and returning access token
client.PostAsJsonAsync(ApiConfigHelper.getAzureAccessToken, certificateCredential).ContinueWith(task =>
{
if (task.Status == TaskStatus.RanToCompletion)
{
var response = task.Result;
if (response.IsSuccessStatusCode)
{
// token = response.Content.ReadAsAsync<string>().Result;
token = response.Content.ReadAsStringAsync().Result;
}
}
});
upload.Wait();
私钥不在X.509证书中。是我得到的例外。
我需要知道我是否可以将证书传递给某个api来获取访问令牌。
子目