Skip to content

Scopes not configured for service account error #341

Closed

Description

@mziccard

This error occurs to me when I try to use default credentials created from the GOOGLE_APPLICATION_CREDENTIALS variable. This is the error I get whenever I try to issue a request:

java.io.IOException: Scopes not configured for service account. Scoped should be specifed by calling createScoped or passing scopes to constructor.
    at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:183)
    at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:76)
    at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:53)
    at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:40)
    at com.google.gcloud.ServiceOptions$1.initialize(ServiceOptions.java:510)
    at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:300)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at com.google.gcloud.spi.DefaultStorageRpc.list(DefaultStorageRpc.java:148)

It seems that to create default credentials based on the env variable we must supply the service scopes. This can be done by changing this line to:

GoogleCredentials.getApplicationDefault().createScoped(scopes);

This would require, however, to change our AuthCredentials.createApplicationDefaults method to accept a set of scopes as a parameter.

Noticeably, scopes are not required to be passed when Google Cloud SDK credentials are used. Is this a desired behavior of the auth library? Should we add this scopes parameter?

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Nov 10, 2015
  2. ajkannan commented on Nov 10, 2015

    @ajkannan

    @mziccard I noticed this too yesterday afternoon while doing auth cleanup. I will add scoping for the ApplicationDefaultCredentials in #337.

  3. aozarov commented on Nov 10, 2015

    @aozarov
    Contributor

    Fixed by #343

  4. added a commit that references this issue on Sep 15, 2022
  5. added a commit that references this issue on Dec 22, 2025
  6. added a commit that references this issue on Jan 22, 2026
  7. added a commit that references this issue on Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨 criticalP0 critical issue. Requires immediate fixapi: coreauthtriage meI really want to be triaged.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

    Sponsor
    SponsoredKunjungi sekarang
    Promo