【问题标题】:Azure connection failed errorAzure 连接失败错误
【发布时间】:2012-10-06 05:35:31
【问题描述】:

我正在使用这个https://xxxx.accesscontrol.windows.net/v2/mgmt/service url 获取服务

ACS 令牌,我收到此错误,

ACS60018:URI 'https://xxx.accesscontrol.windows.net/v2/mgmt/service' 无效 因为它不是基于 'https://xxxx.accesscontrol.windows.net/v2/mgmt/service/'。跟踪 ID: ed498472-6a04-4d51-a6ba-4786f0c67212。时间戳: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;      
        }
    }

我收到了这个错误

“连接尝试失败,因为连接方没有 一段时间后正确响应,或建立连接 失败,因为连接的主机没有响应 157.56.160.192:443"}

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

提前致谢, 沙拉湾

【问题讨论】:

  • 查看these samples 使用 ACS 探索 WebToken。你会发现很多有用的例子。

标签: azure acs


【解决方案1】:

这个错误:

ACS60018:URI 'https://xxx.accesscontrol.windows.net/v2/mgmt/service' 无效,因为它不是基于 'https://xxxx.accesscontrol.windows.net/v2/管理/服务/'。跟踪 ID:ed498472-6a04-4d51-a6ba-4786f0c67212。时间戳:2012-10-16 07:07:09Z

是由于您的管理 URI 上缺少尾随斜杠造成的(OData 规范对此有特别规定)。

【讨论】:

    猜你喜欢
    • 2017-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多