1
votes

i am using service this https://xxxx.accesscontrol.windows.net/v2/mgmt/service url to get

ACS token,i am getting this error,

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

if i try with an application

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;      
        }
    }

i am getting this error

"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"}

team can please tell me how do i get the ACS token by using c# code,

Thanks in Advance, Saravanan

1
check out these samples that explore the WebTokens with ACS. You will find a lot of useful examples.astaykov

1 Answers

3
votes

This error:

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

Is caused by a missing trailing slash on your management URI (the OData spec is particular about this).