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

Storage.readAllBytes() unauthorized when running on App Engine standard with default credentials #1007

Closed
clementdenis opened this issue May 13, 2016 · 2 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@clementdenis
Copy link

Create an application running this code:

StorageOptions.defaultInstance().service().readAllBytes(bucket, objectName)

It will work on a local environment using application default credentials, but it will throw the following error when deployed on App Engine standard (did not try on flexible):

com.google.cloud.storage.StorageException: 401
Login Required
    at com.google.cloud.storage.spi.DefaultStorageRpc.translate(DefaultStorageRpc.java:98)
    at com.google.cloud.storage.spi.DefaultStorageRpc.load(DefaultStorageRpc.java:362)
    at com.google.cloud.storage.StorageImpl$16.call(StorageImpl.java:443)
    at com.google.cloud.storage.StorageImpl$16.call(StorageImpl.java:440)
    at com.google.cloud.RetryHelper.doRetry(RetryHelper.java:181)
    at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:247)
    at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:237)
    at com.google.cloud.storage.StorageImpl.readAllBytes(StorageImpl.java:440)

The workaround is to use Storage.reader() to get a ReadChannel.

@mziccard
Copy link
Contributor

This is strange and I believe it does not depend on us. I need to do some digging but I might have a fix.

@mziccard mziccard added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: storage Issues related to the Cloud Storage API. labels May 13, 2016
@mziccard
Copy link
Contributor

@clementdenis Would you mind giving a try to #1010? that should fix the readAllBytes issue.

suztomo pushed a commit that referenced this issue Feb 1, 2023
…essor job (#1691) (#1007)

* chore: install dependencies through requirements file
Source-Link: https://togithub.com/googleapis/synthtool/commit/35f4cbaf1295a726cb43fd4471129ec74b48e04e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:821ab7aba89af2c7907e29297bba024d4cd5366d0684e5eb463391cdf4edc9ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants