Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ID tokens for user refresh credentials #468

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented Aug 15, 2023

Add ID token support to UserRefreshCredentials

  • add tests
  • manual E2E test to verify it works

Manually tested by running gcloud auth application-default login, and then executing the following:

use Google\Auth\ApplicationDefaultCredentials;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use Firebase\JWT\JWK;
use Firebase\JWT\JWT;

// Get the UserRefreshCredentials from "~/.config/gcloud/application_default_credentials.json",
// and supply the target audience
$credentials = ApplicationDefaultCredentials::getIdTokenCredentials('test-target-audience');
$idToken = $credentials->fetchAuthToken();

// Verify the ID token using the certs from Google
$certUrl = 'https://www.googleapis.com/oauth2/v3/certs';
$client = new GuzzleHttp\Client();
$certs = json_decode($client->send(new Request('GET', $certUrl))->getBody(), true);

$keys = JWK::parseKeySet($certs);
$decoded = JWT::decode($idToken['id_token'], $keys);
var_dump($decoded);

see also googleapis/google-auth-library-nodejs#1811

@bshaffer bshaffer requested a review from a team as a code owner August 15, 2023 16:33
@bshaffer bshaffer marked this pull request as draft August 15, 2023 16:33
@bshaffer bshaffer marked this pull request as ready for review October 3, 2024 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants