1

I'm having a problem authenticating on Crawlera service using HTTPoison.

The crawlera's API documentation says I only need the API Token.

i.e. curl -vx proxy.crawlera.com:8010 -U <API key>: http://httpbin.org/ip

So, I'm having problems setting the authentication options on HTTPoison settings.

I'm trying this 3 options:

HTTPoison.get("url", header, hackney: [:insecure], proxy: 'proxy.crawlera.com:8010', proxy_auth: 'api-token') Error -> (FunctionClauseError) no function clause matching in :hackney.do_connect/7

HTTPoison.get("url", header, hackney: [:insecure], proxy: 'proxy.crawlera.com:8010', proxy_auth: {'api-token',''}) Error -> (ArgumentError) argument error :erlang.bit_size([])

HTTPoison.get("url", header, hackney: [:insecure], proxy: 'api-token:@proxy.crawlera.com:8010') Error -> {"X-Crawlera-Error", "bad_proxy_auth"}

If someone knows how to set correctly the parameters I'll appreciate the help.

Gus
  • 90
  • 1
  • 9
  • 1
    Try `proxy: "proxy.crawlera.com:8010", proxy_auth: {"api-token", ""}` (your second snippet with single quotes changed to double quotes). – Dogbert Oct 23 '17 at 21:48
  • Actually, try this instead: `proxy: {"proxy.crawlera.com", 8010}, proxy_auth: {"api-token", ""}`. The port needs to be separate. – Dogbert Oct 23 '17 at 21:54

1 Answers1

2
  1. The proxy argument should be a tuple of the host and port.
  2. You need to use binaries instead of charlists for the host and both the elements of proxy_auth.

The following should work:

proxy: {"proxy.crawlera.com", 8010}, proxy_auth: {"api-token", ""}
Dogbert
  • 212,659
  • 41
  • 396
  • 397