overture8 / mangoex

Elixir wrapper for the MangoPay API
3 stars 3 forks source link

Httpotion returns 403 Forbidden #18

Closed artmoni closed 6 years ago

artmoni commented 6 years ago

Since 3 november when Mangopay has changed its certificate, Httpotion can no more connect to the sandbox api.

potion=HTTPotion.post 'https://api.sandbox.mangopay.com/oauth/token',
                      [
                        body: "grant_type=" <> URI.encode_www_form("client_credentials"),
                        headers: [
                          "Authorization": "Basic abcdefg1234567890=",
                          "Content-Type": "application/x-www-form-urlencoded"]
                      ]

potion|> IO.inspect()

The connection always returns HTTP 403

%HTTPotion.Response{body: "<html>\r\n<head><title>403 Forbidden</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>403 Forbidden</h1></center>\r\n<hr><center>cloudflare-nginx</center>\r\n</body>\r\n</html>\r\n",
 headers: %HTTPotion.Headers{hdrs: %{"cf-ray" => "3ba003321da968d2-CDG",
    "connection" => "keep-alive", "content-length" => "173",
    "content-type" => "text/html", "date" => "Tue, 07 Nov 2017 11:39:31 GMT",
    "server" => "cloudflare-nginx"}}, status_code: 403}

This problems doesn't occur using Httpoison client (https://github.com/artmoni/mangoex/pull/2)

artmoni commented 6 years ago

solved by https://github.com/overture8/mangoex/commit/bd3dcb16df28b6603dfa22d4c0feb6ba03b9c096