试图以编程方式连接的Azure禁止异常

时间:2016-06-08 00:28:54

标签: azure azure-sdk-.net

我有以下代码:

var authority = "https://login.microsoftonline.com/XXX-XXXX-XXXXX-XXXXXX/oauth2/authorize";
var clientId = "YYY-YYYY-YYYYY-YYYYYY";
var appKey = "xxxxxxxxxxxxx";
var resource = "https://management.core.windows.net/";
var authContext = new AuthenticationContext(authority, true);
var clientCredential = new ClientCredential(clientId, appKey);
var result = authContext.AcquireToken(resource, clientCredential);
var token = result.AccessToken;
var creds = new TokenCloudCredentials("ZZZ-ZZZZ-ZZZZZ-ZZZZZZ", token);
var client = new WebSiteManagementClient(creds);
var data = client.WebSites.Get("eastuswebspace", "some-site", new WebSiteGetParameters());

我在client.WebSites.Get()电话上收到此错误:

  

服务器无法验证请求。验证   证书有效且与此订阅相关联

但我没有使用证书,我正在使用AuthenticationContext

我做错了什么?

0 个答案:

没有答案