{"id":25872084,"url":"https://github.com/aktsk/gcp_auth","last_synced_at":"2025-03-02T07:37:23.687Z","repository":{"id":12129757,"uuid":"70989833","full_name":"aktsk/gcp_auth","owner":"aktsk","description":"GCP(Google Cloud Platform) auth library using Application Default Credentials for Elixir.","archived":false,"fork":false,"pushed_at":"2019-10-01T22:14:49.000Z","size":7,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":50,"default_branch":"master","last_synced_at":"2024-04-26T22:03:18.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aktsk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-15T13:37:16.000Z","updated_at":"2024-04-26T22:03:18.608Z","dependencies_parsed_at":"2022-07-21T13:32:26.004Z","dependency_job_id":null,"html_url":"https://github.com/aktsk/gcp_auth","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktsk%2Fgcp_auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktsk%2Fgcp_auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktsk%2Fgcp_auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aktsk%2Fgcp_auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aktsk","download_url":"https://codeload.github.com/aktsk/gcp_auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241476387,"owners_count":19968902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-02T07:37:22.840Z","updated_at":"2025-03-02T07:37:23.634Z","avatar_url":"https://github.com/aktsk.png","language":"Elixir","readme":"# GCPAuth\n\n[![Build Status](https://travis-ci.org/aktsk/gcp_auth.svg?branch=master)](https://travis-ci.org/aktsk/gcp_auth)\n[![Hex.pm](https://img.shields.io/hexpm/v/gcp_auth.svg)](https://hex.pm/packages/gcp_auth)\n[![Hex.pm](https://img.shields.io/hexpm/l/gcp_auth.svg)](https://github.com/aktsk/gcp_auth/blob/master/LICENSE)\n\nGCP (Google Cloud Platform) auth library using [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials\n).\nThis is intended to be used for [Server to Server Applications](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).\n\n\n## Installation and Usage\n\nAdd `:gcp_auth` to `application` and `deps` in `mix.exs`.\n\n```elixir\ndef deps do\n  [{:gcp_auth, \"~\u003e 0.1\"}]\nend\n\ndef application do\n  [applications: [:gcp_auth]]\nend\n```\n\nAnd add `:scopes` to your `config.ex`.\nThe full list of OAuth2 scopes for Google APIs can be seen at https://developers.google.com/identity/protocols/googlescopes\n\n```elixir\nconfig :gcp_auth,\n  scopes: [\"https://www.googleapis.com/auth/devstorage.read_write\"]\n```\n\nTo get access token, call `GCPAuth.Token.get()`.\n\n```elixir\n\u003e GCPAuth.Token.get()\n\"xxxx.yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\"\n```\n\n### Examples\n\nAn example for uploading a file to GCS (Google Cloud Storage) is as follows:\n\n```elixir\naccess_token = GCPAuth.Token.get()\nbucket = \"your-bucket\"\nupload_path = \"uploads/filename\"\nuri = %URI{scheme: \"https\",\n           host: \"www.googleapis.com\",\n           path: \"/upload/storage/v1/b/#{bucket}/o\",\n           query: \"uploadType=media\u0026predefinedAcl=publicRead\u0026name=#{upload_path}\"}\nlocal_path = \"path/to/existing/localfile\"\nbody = {:file, local_path}\nheaders = %{\"Authorization\" =\u003e \"Bearer #{access_token}\"}\nHTTPoison.post(uri, body, headers)\n```\n\n\n## Configuration\n\n### Disabling\n\nTo disable GCPAuth at specific environments e.g. `dev` or `test`, set `:enabled` to `false`.\n\n```elixir\nconfig :gcp_auth,\n  enabled: false\n```\n\n### Overriding Application Default Credentials\n\nBy default, GCPAuth uses [ADC (Application Default Credentials)](https://developers.google.com/identity/protocols/application-default-credentials\n).\nThat is to say\n\n1. If the environment variable GOOGLE_APPLICATION_CREDENTIALS is specified, the file is used as the credentials file.\n2. If `~/.config/gcloud/application_default_credentials.json` exists, it is used. This wellknown file is created by running `gcloud auth application-default login`.\n3. (Not supported for now) If you are running in GAE (Google App Engine), the built-in service account associated with the application will be used.\n4. If you are running in GCE (Google Compute Engine), the built-in service account associated with the virtual machine instance will be used.\n\nYou can override this by adding `:credentials_file` to `config.ex`.\n\n```elixir\nconfig :gcp_auth,\n  credentials_file: \"credentials.json\",\n  scopes: [\"https://www.googleapis.com/auth/devstorage.read_write\"]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faktsk%2Fgcp_auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faktsk%2Fgcp_auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faktsk%2Fgcp_auth/lists"}