Skip to content

Goth used default scopes, instead my #187

@npolevara

Description

@npolevara

google-iex.json:

{
    "type": "service_account",
    "project_id": "sheetapi-459712",
    "private_key_id": "d9baee339d8485e831f2640600480ccfbe07e6fc",
    "private_key": "-----BEGIN PRIVATE KEY-----\n MY_PRIVATE_KEY \n-----END PRIVATE KEY-----\n",
    "client_email": "exs@api.iam.gserviceaccount.com",
    "client_id": "12345",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/....",
    "universe_domain": "googleapis.com"
}

config/config.exs:
config :goth, json: File.read!("google-iex.json")

in Module:

def gen_token do
  scopes = [
      "https://www.googleapis.com/auth/drive",
      "https://www.googleapis.com/auth/spreadsheets"
   ]

  Goth.Token.fetch(%{scope: Enum.join(scopes, " ")})
end

gen_token =>

 {:ok,
 %Goth.Token{
   token: "some token",
   type: "Bearer",
   scope: "https://www.googleapis.com/auth/cloud-platform",
   sub: nil,
   expires: 1747161673,
   account: nil
 }}

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