How to resolve error in Google Storage Client in Symfony?

I am developing a project in Symforny 5 and I want to use Google Cloud Storage, install thephpleague / flysystem-bundle with superbalist / flysystem-google-storage support, as indicated in the documentation, generate the credentials.json in Google Console and the bucket, but I get the following error:

{
 "error": {
 "code": 401,
 "message": "Invalid Credentials",
 "errors": [
 {
  "message": "Invalid Credentials",
  "domain": "global",
  "reason": "authError",
  "locationType": "header",
  "location": "Authorization"
 }
 ]
}
}
vendorgooglecloud-coresrcRequestWrapper.php (line 362)

Configurations:

flysystem:
storages:
    default.storage:
        adapter: 'local'
        options:
            directory: '%kernel.project_dir%/var/storage/default'

    gcs.storage:
        adapter: 'gcloud'
        options:
            client: 'gcloud_client_service' # The service ID of the GoogleCloudStorageStorageClient instance
            bucket: 'test-storage'
            #prefix: 'optional/path/prefix'
            api_url: 'https://storage.googleapis.com'

In service.yml

gcloud_client_service:
    class: GoogleCloudStorageStorageClient
    arguments:
        - projectId: 'storage-project'
        - keyFilePath: '../credentials.json'

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *