Server to server app authentication issue

API Endpoint(s) and/or Zoom API Event(s)

Setting up a new Server to server internal app and running into an issue getting the access_token. I am using PHP on my server and attempting a curl request to the endpoint. I did find where someone else posted about this and have a code example very similar to theirs but I am still getting the following error message.

{“reason”:“Bad Request”,“error”:“invalid_request”}

How To Reproduce

	$endpoint = '' . $int['api_key'];

	$headers[] = "Authorization: Basic " . base64_encode($int['username'] . ":" . $int['password']);
	$headers[] = "Content-Type: application/x-www-form-urlencoded";

	$body = array(
		'grant_type' => 'client_credentials'

	// CURL to GET access_token
	$ch = @curl_init();
	@curl_setopt($ch, CURLOPT_POST, true);
	@curl_setopt($ch, CURLOPT_URL, $endpoint);
	@curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($body));
	@curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$response = @curl_exec($ch);
	$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
	$curl_errors = curl_error($ch);

@geoff.crego ,

$endpoint = ‘’ . $int[‘api_key’];

This needs to be account id, not api key

$headers = "Authorization: Basic " . base64_encode($int[‘username’] . “:” . $int[‘password’]);

This needs to be appID and appSecret, not username and password

Thanks for the reply. It helped me notice that I had fat fingered one of the parameters in my code. Once I fixed that everything is working as expected.

While you think I am using the wrong values but I am pulling those from a database object where I stored the correct values in those fields.

1 Like

@geoff.crego , glad that I was able to help, indirectly nonetheless :smiley: