hibp icon indicating copy to clipboard operation
hibp copied to clipboard

HTTP Error 403

Open thehappydinoa opened this issue 7 years ago • 6 comments

I am currently getting this error from hibp -f info.txt: Hibp::HttpClient::ClientError: GET to https://haveibeenpwned.com/api/breachedaccount/<email> returned status 403 - options: {:query=>nil}

thehappydinoa avatar Oct 30 '18 00:10 thehappydinoa

Same, not sure what is wrong

ghost avatar Dec 07 '18 00:12 ghost

Same here!

Fortesqueu avatar Jan 28 '19 14:01 Fortesqueu

403 | Forbidden — no user agent has been specified in the request

(from API documentation) I'd like to know how to specify a "user agent", any idea?

Fortesqueu avatar Jan 28 '19 14:01 Fortesqueu

Bummer. Just came across this too... No update or idea on how to avoid this?

exhaustdad avatar Mar 04 '19 23:03 exhaustdad

Folks, everyone is getting 403 for the following reason: "Specifying the user agent Each request to the API must be accompanied by a user agent request header. Typically this should be the name of the app consuming the service. A missing user agent will result in an HTTP 403 response."

GET https://haveibeenpwned.com/api/{service}/{parameter} User-Agent: [your app name]

https://haveibeenpwned.com/API/v2#UserAgent

cwanderley avatar May 28 '19 22:05 cwanderley

I've used the following code and worked well, any problem! $agent = array('http' => array('user_agent' => 'any code here')); //could be the initial letters of your name $curl = curl_init('https://haveibeenpwned.com/api/v2/breachedaccount/test@example); //Creates a new cURL resource curl_setopt($curl, CURLOPT_USERAGENT, $agent ); //Set URL options, CURLOPT_URL is the URL to fetch at $path curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //Set URL options, true to return transfer as a string $xmlResponse = curl_exec($curl); //Execute the given cURL session after options are set $info = curl_getinfo($curl); //Get information about the transfer curl_close($curl); //Close cURL resource

$hibp_result=json_decode($xmlResponse,true); //Convert a string to a PHP variable

cwanderley avatar May 29 '19 21:05 cwanderley