Skip to content

Getting 401 unauthorized client when trying to impersonate with service account #159

@tonyzeng91

Description

@tonyzeng91

Hi - I am getting the follow error when trying to impersonate a service account.

{:error, %RuntimeError{message: "unexpected status 401 from Google\n\n{\n  \"error\": \"unauthorized_client\",\n  \"error_description\": \"Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.\"\n}\n"}}
# steps to impersonate
credentials = "credentials.json" |> File.read!() |> Jason.decode!()
claims = %{"sub" => "<IMPERSONATED_ACCOUNT_EMAIL>", "scope" => "https://www.googleapis.com/auth/cloud-platform"}
Goth.Token.fetch(source: {:service_account, credentials, [claims: claims]})

I am able to impersonate with a similar library in Python. Any idea why I am getting this error using the Goth lib?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions