How to get a paypal token in asp.net mvc?

0

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.

    
asked by anonymous 10.02.2018 / 20:46

0 answers