【发布时间】:2018-01-26 21:32:57
【问题描述】:
我需要访问一个由承载身份验证控制的门户。客户端需要获取身份验证令牌,然后将其添加到每个请求中
网址 ~/token 方法 POST 内容类型应用程序/x-www-form-urlencoded 有效载荷 grant_type=password&username=UserName&password=Password
**如何将包含授权类型、用户名和密码的有效负载添加到我的代码中**
到目前为止,我的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
namespace ConsoleRestClient
{
class Program
{
static void Main(string[] args)
{
string URI = "https://token";
WebRequest request = WebRequest.Create(URI);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
}
}`
}
【问题讨论】: