我可以访问 Versionone 的 Summer2013。我正在尝试使用 Json 示例通过新的 query.v1 访问它,该示例使用如下所示的客户端标头 cookie:
_client.Headers["Cookie"] = ".V1.Ticket.VersionOne.Web=" + ticket;
如何为 cookie 生成 .V1.Ticket.VersionOne.Web 票证?
Json 示例:https ://github.com/versionone/versionone-oauth2-examples/blob/master/csharp/YamlClient/Program.cs
注意:我已经通过这些说明生成了一个 OAuth 2 令牌,但它不包含票证。 https://community.versionone.com/Developers/Developer-Library/Documentation/API/Security/Oauth_2.0_Authentication/Using_OAuth_2.0_for_Web_Server_Applications
这是代码:
namespace V1Json
{
class JsonClient
{
private readonly Uri _url;
private readonly string _ticket;
private WebClient _client;
public JsonClient(string url, string ticket)
{
_url = new Uri(url);
_ticket = ticket;
_client = new WebClient { Encoding = Encoding.UTF8 };
_client.Headers["Cookie"] = ".V1.Ticket.VersionOne.Web=" + ticket;
}
public List<List<dynamic>> GetResultSets(string querybody)
{
var resultbody = _client.UploadString(_url, "SEARCH", querybody);
return JsonConvert.DeserializeObject<List<List<dynamic>>>(resultbody);
}
}
class Program
{
static void Main(string[] args)
{
var url = "https://versionone-test.acme.com/summer13_demo/query.v1";
var authTicket = "AAEAAGvqd3ylmW0FphkxxxHASSMoCrEa...";
var client = new JsonClient(url, authTicket);