In the end, I managed to get this work, by generating a key from the service account
. From:
Please not that once you generated you will automatically download it. A download button will not be available anymore. So make sure you have the key after generated it. I would expect to have a download button for the service account
, like I have for OAuth 2.0 Client IDs
(see my post). But I don't :(.
Finally my code:
$storage = new StorageClient([
'projectId' => 'projectId' => 'my project id',
'keyFile' => json_decode('{
"type": "service_account",
"project_id": "my project id",
"private_key_id": "my key id",
"private_key": "my key",
"client_email": "[email protected]",
"client_id": "client id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "url here"
}', true)
]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…