Skip to content

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

Closed

Description

@clementdenis

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.

Activity

  1. mziccard commented on May 13, 2016

    @mziccard
    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.

  2. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: storageIssues related to the Cloud Storage API.
    on May 13, 2016
  3. mziccard commented on May 14, 2016

    @mziccard
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions