2012-10-16 74 views
1

我使用服务这https://xxxx.accesscontrol.windows.net/v2/mgmt/service网址获得Azure的连接失败错误

ACS令牌,我得到这个错误,

ACS60018: The URI 'https://xxx.accesscontrol.windows.net/v2/mgmt/service' is not valid since it is not based on 'https://xxxx.accesscontrol.windows.net/v2/mgmt/service/'. Trace ID: ed498472-6a04-4d51-a6ba-4786f0c67212. Timestamp: 2012-10-16 07:07:09Z

,如果我尝试与应用

class Program 
    { 
     public const string serviceIdentityUsernameForManagement = "ManagementClient"; 
     public const string serviceIdentityPasswordForManagement = "xxxxxxxxxxx="; 
     public const string serviceNamespace = "xxxxx"; 
     public const string acsHostName = "accesscontrol.windows.net"; 
     public const string acsManagementServicesRelativeUrl = "v2/mgmt/service/"; 
     static string cachedSwtToken;   

     static void Main(string[] args) 
     { 
      // 
      // Request a token from ACS 
      // 
      WebClient client = new WebClient(); 
      client.BaseAddress = string.Format(CultureInfo.CurrentCulture, 
               "https://{0}.{1}", 
               serviceNamespace, 
               acsHostName); 
      NameValueCollection values = new NameValueCollection(); 
      values.Add("grant_type", "client_credentials"); 
      values.Add("client_id", serviceIdentityUsernameForManagement); 
      values.Add("client_secret", serviceIdentityPasswordForManagement); 
      values.Add("scope", client.BaseAddress + acsManagementServicesRelativeUrl); 

      byte[] responseBytes = client.UploadValues("/v2/OAuth2-13", "POST", values); 

      string response = Encoding.UTF8.GetString(responseBytes); 

      // Parse the JSON response and return the access token 
      JavaScriptSerializer serializer = new JavaScriptSerializer(); 

      Dictionary<string, object> decodedDictionary = serializer.DeserializeObject(response) as Dictionary<string, object>; 

      string returnToken= decodedDictionary["access_token"] as string;  
     } 
    } 

我我得到这个错误

"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 157.56.160.192:443"}

团队可以请告诉我,我该如何使用C#代码获取ACS令牌,

由于事先 Saravanan

+0

查看[这些示例](https://github.com/RobBlackwell/webtokens)探索与ACS的WebTokens。你会发现很多有用的例子。 – astaykov

回答

3

此错误:

ACS60018: The URI 'https://xxx.accesscontrol.windows.net/v2/mgmt/service' is not valid since it is not based on 'https://xxxx.accesscontrol.windows.net/v2/mgmt/service/'. Trace ID: ed498472-6a04-4d51-a6ba-4786f0c67212. Timestamp: 2012-10-16 07:07:09Z

由失踪斜线引起在你的管理URI上(OData规范特别关注这个)。

+0

非常感谢,投票了 – Eedoh

相关问题