无法使用 REST 获取 IssueToken
在白皮书中,它说我们可以使用 REST 来请求令牌,然后使用令牌附加到我们要触发的请求,然后可以调用服务总线中的服务,但是,我无法获取令牌
下面是我用来进行 REST 调用的代码,我可以获得结果,但这是一个 html 错误页面。 我没有得到任何令牌...我确信我的解决方案名称和密码是正确的。 因为我在云中的服务是 RESTful 服务,当我将服务端点放到浏览器上时,它要求我输入我的解决方案名称和密码,我输入的内容与下面代码中使用的相同,它工作得很好。谁能
告诉我为什么下面的代码我无法理解白色所说的内容?
public static String call() {
try {
HttpClient client = new HttpClient();
String uri = String.format("https://accesscontrol.windows.net/isssuetoken.aspx?u=%s&p=%s", "solutionname", "password");
log.debug("Out going uri is : " + uri);
GetMethod get = new GetMethod(uri);
int status = client.executeMethod(get);
byte[] responseBody = get.getResponseBody();
log.debug("status return is : " + status);
if (status == HttpStatus.SC_OK) {
return new String(responseBody);
}
} catch (Exception ex) {
log.error("Error while calling AccessControl protal.", ex);
}
return null;
}
================ 以下是白皮书中的文字============
https://accesscontrol.windows.net/isssuetoken.aspx?u={solution-name}&p={password}
响应包含.NET 访问控制服务中保存的令牌的引用 cookie(纯文本格式)。 通过将 cookie 值添加到名为“X-MS-Identity-Token”的自定义 HTTP 标头中的传出 HTTP 请求,客户端可以使用 cookie 来访问中继服务。 使用此技术时,Microsoft 强烈建议使用 HTTPS 来保护线路上的 cookie 值。 有关 .NET 访问控制服务的更多信息,以及具体了解如何将其与您自己的服务结合使用(不仅仅是通过 .NET 服务总线),请参阅随附的名为 .NET 开发人员指南的白皮书访问控制服务。
In the white paper, it said that we can use REST to ask for the token then use the token to attache to the request we are going to fire, then can invoke the service in the service bus, how ever, i cannot get the token
Bellow are the codes i use to make REST call, i can get the result, but which was a html error page..
i didn`t get any token...and i am sure my solution name and password are correct. coz my service in the cloud are RESTful service, when i put the service endpoint onto the broswer, it ask me to input my solution name and password, i input the same as in use in the code below, and it work just fine...
can anyone tell me why the code below i cannot get what the white said??
public static String call() {
try {
HttpClient client = new HttpClient();
String uri = String.format("https://accesscontrol.windows.net/isssuetoken.aspx?u=%s&p=%s", "solutionname", "password");
log.debug("Out going uri is : " + uri);
GetMethod get = new GetMethod(uri);
int status = client.executeMethod(get);
byte[] responseBody = get.getResponseBody();
log.debug("status return is : " + status);
if (status == HttpStatus.SC_OK) {
return new String(responseBody);
}
} catch (Exception ex) {
log.error("Error while calling AccessControl protal.", ex);
}
return null;
}
================ Below are the words from white paper =============
https://accesscontrol.windows.net/isssuetoken.aspx?u={solution-name}&p={password}
The response contains a reference cookie (in plain text format) to a token held within the .NET Access Control Service. The client can use the cookie to gain access to the relay service by adding the cookie value to outgoing HTTP requests in a custom HTTP header named “X-MS-Identity-Token”. When using this technique, Microsoft strongly recommends using HTTPS to protect the cookie value on the wire. For more information on the .NET Access Control Service, and to learn specifically about how you can use it in conjunction with your own services (not just through the .NET Service Bus), see the accompanying whitepaper called A Developer’s Guide to the .NET Access Control Service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上面的类似是错误的...
白皮书有误,
链接中多了一个“s”,
它应该是
String uri = String.format("https://accesscontrol. windows.net/issuetoken.aspx?u=%s&p=%s", "解决方案名称", "密码");
the like above is wrong...
the white paper get a misstake,
there is one extra 's' in the link,
it should be
String uri = String.format("https://accesscontrol.windows.net/issuetoken.aspx?u=%s&p=%s", "solutionname", "password");
仅供参考,这根本不是 REST。 简单来说就是RPC。
FYI, this is not REST at all. It is simply RPC.