Hi,
Thanks for the php library, it's been of great help.
I'm having an issue trying to use this library on a hosting service that doesn't support persistent disk storage and deploys via git push (like Heroku). This means I can't upload the credentials JSON file unless I put it in my .git repo, which I'd like to avoid for security reasons.
I see there is support for using environmental variables for Google Cloud platform. But I can't see any support for using environmental variables to store the actual credential values. I'd like to be able to set environmental variables like:
GOOGLE_API_PRIVATE_KEY=-----BEGIN PRIVATE KEY-----\n........
[email protected]
Would it be possible to adjust the setAuthConfig to read from environmental variables? I think it would be great and allow support on cloud hosting platforms.
@k0nG you don't need persistent disk - setAuthConfig supports an array argument. This allows flexibility with environment variables, or wherever you would like to store your credentials:
$auth = [
"type" => "service_account",
"project_id" => getenv('GOOGLE_PROJECT_ID'),
"private_key" => getenv('GOOGLE_API_PRIVATE_KEY'),
"client_email" => getenv('GOOGLE_API_CLIENT_EMAIL'),
"client_id" => getenv('GOOGLE_API_CLIENT_ID'),
"auth_uri" => "https://accounts.google.com/o/oauth2/auth",
"token_uri" => "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url" => "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url" => getenv('GOOGLE_API_CLIENT_CERT_URL')
];
$client->setAuthConfig($auth);
oh super. Sorry I had a look in the code and I couldn't see that.
Thanks for quick reply.
Most helpful comment
@k0nG you don't need persistent disk -
setAuthConfigsupports an array argument. This allows flexibility with environment variables, or wherever you would like to store your credentials: