GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add full support for service account impersonation · Issue #353 · googleapis/google-auth-library-ruby

Add full support for service account impersonation #353

New issue
Copy link
New issue
Copy link
Closed
Closed
Add full support for service account impersonation#353
Copy link
Assignees
aandreassa
Labels
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@quartzmo
quartzmo
opened on Nov 15, 2021
Issue body actions

Regarding the support for service account impersonation that was discussed in #346 and that I added in #347, I noticed that googleapis/google-auth-library-java/pull/613 and golang/oauth2/pull/468 go beyond accepting a token obtained externally from projects.serviceAccounts.generateAccessToken and actually perform the RPC to obtain the token when provided with the appropriate service account credentials. Should this library do the same?

Reacted by Pat Leamon, Tobias Schelhas, shpml, Damien Merenne, Grace Carr, Robert Heise, manu-crealytics, Santi, Gregory Barry, Oliver Morgan and 2 more

Activity

  1. quartzmo
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Nov 15, 2021
  2. konalegi commented on Aug 2, 2024

    @konalegi
    konalegi
    on Aug 2, 2024
    More actions

    @quartzmo do you plan to implement this feature?

  3. konalegi commented on Aug 2, 2024

    @konalegi
    konalegi
    on Aug 2, 2024
    More actions

    @quartzmo I've tried to implement service account impersonation with ADC, It worked locally, although I have no idea if I'm moving right direction, since not very familiar with all this kitchen. If you have a time could you please have a look and give suggestion where to move next.
    https://github.com/googleapis/google-auth-library-ruby/pull/485/files
    Thank you!

  4. cglwn commented on Feb 20, 2025

    @cglwn
    cglwn
    on Feb 20, 2025
    More actions

    For others who run into this, there's the googleauth-extras gem.

  5. henrahmagix commented on May 5, 2025

    @henrahmagix
    henrahmagix
    on May 5, 2025
    More actions

    @viacheslav-rostovtsev Hi, thanks for implementing service account impersonation in #499!

    How may I use it for Google Cloud Storage?

    I've tried this but the source_credentials cannot fetch an access token 🤔

    base_credentials = Google::Cloud::Storage.default_credentials
    base_credentials.fetch_access_token! # testing that default credentials works
    # {"access_token"=>"<redacted>",
    #  "expires_in"=>3599,
    #  "token_type"=>"Bearer",
    #  "id_token"=>"<redacted>",
    #  "granted_scopes"=>"https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/userinfo.email openid"}
    
    creds = Google::Auth::ImpersonatedServiceAccountCredentials.new(
      base_credentials:,
      impersonation_url: 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken',
      scope: [Google::Apis::StorageV1::AUTH_CLOUD_PLATFORM]
    )
    
    storage = Google::Cloud::Storage.new(project_id: 'myproject', credentials: creds.source_credentials)
    
    # This fails:
    storage.signed_url('mybucket', 'path/to/file.txt', method: "GET", expires: 300, version: :v4)
    # Google::Cloud::Storage::SignedUrlUnavailable: Service account credentials 'issuer (client_email)' is missing. To generate service account credentials see https://cloud.google.com/iam/docs/service-accounts
    
    creds.source_credentials.client.issuer
    # nil
    
    # This also fails: is this the core issue?
    creds.source_credentials.client.fetch_access_token!
    # Signet::AuthorizationError: Authorization failed. Server message:
    # {
    #   "error": "unsupported_grant_type",
    #   "error_description": "Invalid grant_type: "
    # }

    Alternatively, @cglwn I tried using googleauth-extras but similarly it couldn't fetch a token for the service account it should be impersonating 🤔

    Is there something wrong with how I'm passing credentials into Google::Cloud::Storage?

  6. BSick7 commented on Dec 11, 2025

    @BSick7
    BSick7
    on Dec 11, 2025
    More actions

    I'm seeing the same @henrahmagix.
    When debugging, I found that the auth header was not being added to the request.

    I traced it to this section: https://github.com/googleapis/google-auth-library-ruby/blob/main/lib/googleauth/impersonated_service_account.rb#L299-L301

          def prepare_auth_header
            auth_header = {}
            @source_credentials.updater_proc.call auth_header
            auth_header
          end
    

    auth_header is unchanged when performing updater_proc. Instead, the auth_header is copied, changed, then returned.
    It should read:

          def prepare_auth_header
            @source_credentials.updater_proc.call {}
          end
    
    Reacted by Henry Blyth and Aren Clissold
  7. iamKunalGupta commented on Jul 14, 2026

    @iamKunalGupta
    iamKunalGupta
    on Jul 14, 2026
    More actions

    Hi there! is there anytime we can expect @BSick7's PR to get merged?
    We are currently monkeypatching it ourselves ubicloud/ubicloud#5886

  8. aandreassa
    self-assigned this
    on Jul 23, 2026
  9. aandreassa commented on Jul 23, 2026

    @aandreassa
    aandreassa
    on Jul 23, 2026
    Contributor
    More actions

    @henrahmagix @iamKunalGupta I just released a new version of googleauth in https://rubygems.org/gems/googleauth/versions/1.17.2. PTAL.

    Reacted by Kunal Gupta
  10. aandreassa
    closed this as completedon Jul 23, 2026
  11. henrahmagix commented on Jul 23, 2026

    @henrahmagix
    henrahmagix
    on Jul 23, 2026
    More actions

    Thank you thank you!

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

Metadata

Metadata

Assignees

  • @aandreassa
    aandreassa

Labels

type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.