php-docs-samples icon indicating copy to clipboard operation
php-docs-samples copied to clipboard

[Pub/Sub]: add sample for decoding and verifying JWT from Pub/Sub

Open anguillanneuf opened this issue 3 years ago • 0 comments

Please add a sample in this directory and show how to decode and verify a JWT included in the header of a Pub/Sub push message (when authenticated push is enabled). The other language (Go, Node.js, Java, Python) samples already exist. This sample will be used alongside those.

I'm not sure if PHP has a cloud client library for this task (please find out if you can), but it appears to have an API client library google-api-php-client that does the job, specifically, the verifyIdToken() method.

You can use Google's public keys referenced here to verify JWTs from the real Pub/Sub service. For writing tests, you can use mocked public keys in other language samples.

You can use the region tag gaeflex_net_pubsub_auth_push for this sample.

anguillanneuf avatar Dec 15 '20 23:12 anguillanneuf