googleapis / google-cloud-php

Google Cloud Client Library for PHP
https://cloud.google.com/php/docs/reference
Apache License 2.0
1.1k stars 436 forks source link

Unable to use Google Cloud Pub/Sub with emulator #7715

Open rpkamp opened 1 month ago

rpkamp commented 1 month ago

Whenever I create an instance of PubSubClient and do something with it in my development environment, using the PubSub emulator, I get the following exception:

Google\ApiCore\ValidationException: Could not construct ApplicationDefaultCredentials

Looking into the code it seems the library can't construct credentials to use for PubSub, but it shouldn't even need it, as the emulator doesn't require any credentials.

The v1 version of the library also didn't need any credentials.

Environment details

Steps to reproduce

  1. Set environment variable PUBSUB_EMULATOR_HOST
  2. Create new PubSubClient
  3. Do something with client
pulzarraider commented 4 weeks ago

You can try some example keys: key mentioned in #7187 or example-key.json.

However, you'll then face another issue: the library generates HTTPS links, while Pub/Sub only supports HTTP. This should be addressed by my merge request, which is currently awaiting approval.