我使用服務這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
查看[這些示例](https://github.com/RobBlackwell/webtokens)探索與ACS的WebTokens。你會發現很多有用的例子。 – astaykov