I need to access a Portal which is controlled with Bearer Authentication. Client needs to obtain authentication token then add it to each request
URL ~/token Method POST Content-Type application/x-www-form-urlencoded Payload grant_type=password&username=UserName&password=Password
**How do i add the payload which includes the grant type and username and password to my code **
so far my code is as follows :
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";
}
}`
}