Follow the paypal documentation: here to get token.
Follow the code below:
[HttpPost]
static async Task<HttpStatusCodeResult> Token()
{
var authorization = new
{
Username = "mat.miranda",
Password = "xxxxxxxxxxxxx"
};
var url = "https://api.sandbox.paypal.com/v1/oauth2/token";
HttpResponseMessage response = await client.PostAsJsonAsync(url, authorization);
return new HttpStatusCodeResult(response.StatusCode);
}
The "Unauthorized"
value is being returned. Using the "Postman" tool works fine, it just is not working for ASP.NET.