-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Description
I'm attempting to use ServiceAccountJwtAccessCredentials to connect to a 3rd-party google cloud endpoint. AFAICT there's no example for using this class, and I haven't been able to get it to work. I've got a python example working, so I know the audience and whatnot are correct. I've cobbled together some code based on the ServiceAccountCredentials example, but I can't tell what I'm doing wrong. The error I'm getting from the API is 401: "jwt is missing".
`
$path = 'cred.json';
$sa = new ServiceAccountJwtAccessCredentials($path);
$metadata = $sa->updateMetadata(
[
'issuer' => 'ham@sandwich.iam.gserviceaccount.com',
'client_email' => 'ham@sandwich.iam.gserviceaccount.com',
'audience' => 'https://ham-sandwich.a.run.app'
],
"https://accounts.google.com/o/oauth2/auth" # auth_uri
);
$middleware = new AuthTokenMiddleware($sa);
$stack = HandlerStack::create();
$stack->push($middleware);
$client = new Client([
'handler' => $stack,
'base_uri' => $BASE_URI,
'auth' => 'google_auth'
]);
$res = $client->request('POST', $SERVICE_URI, [
['body' => json_encode($quote_data)]
]);
`
Can an example for using this class be added to the docs?
Metadata
Metadata
Assignees
Labels
No labels