{"id":13509541,"url":"https://github.com/googleapis/elixir-google-api","last_synced_at":"2025-05-14T14:08:02.661Z","repository":{"id":24483861,"uuid":"101434552","full_name":"googleapis/elixir-google-api","owner":"googleapis","description":"Elixir client libraries for accessing Google APIs.","archived":false,"fork":false,"pushed_at":"2025-04-12T13:18:22.000Z","size":71889,"stargazers_count":1043,"open_issues_count":111,"forks_count":465,"subscribers_count":64,"default_branch":"main","last_synced_at":"2025-04-12T13:57:34.764Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hex.pm/users/google-cloud","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googleapis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-08-25T19:09:23.000Z","updated_at":"2025-04-12T13:18:26.000Z","dependencies_parsed_at":"2025-04-12T12:52:00.590Z","dependency_job_id":"1ce3c97c-6957-459c-9604-6f4bf612fa2e","html_url":"https://github.com/googleapis/elixir-google-api","commit_stats":{"total_commits":9479,"total_committers":24,"mean_commits":394.9583333333333,"dds":0.3975102858951366,"last_synced_commit":"c205402e1ba0b96e4f1a476cd1dc23b5e30c69e3"},"previous_names":["googlecloudplatform/elixir-google-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Felixir-google-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Felixir-google-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Felixir-google-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Felixir-google-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googleapis","download_url":"https://codeload.github.com/googleapis/elixir-google-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159461,"owners_count":22024562,"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":"2024-08-01T02:01:09.264Z","updated_at":"2025-05-14T14:07:57.650Z","avatar_url":"https://github.com/googleapis.png","language":"Elixir","readme":"# GoogleApis\n\nThis repository contains all the client libraries to interact with Google APIs.\nThese client libraries are created under `clients/` and each should contain its\nown README.\n\nThe main folder contains the code necessary to generate these client libraries.\n\n**NOTE: These generated clients are under development and should be considered\nexperimental!**\n\n\n## Usage\n\n### Installation\n\nAll available Google API clients can be found [on hex.pm][hex_pm]. Add a client\nto your project's `mix.exs` under `deps`:\n\n```ex\ndefmodule YourApplication.Mixfile do\n  use Mix.Project\n  #...\n\n  # Run \"mix help deps\" to learn about dependencies.\n  defp deps do\n    [\n      {:google_api_storage, \"~\u003e 0.19.0\"},\n      {:goth, \"~\u003e 1.2.0\"}\n    ]\n  end\nend\n```\n\n\u003e Note the [goth][goth] package, which handles Google Authentication, is also\n\u003e required.\n\nNext, run `mix deps.get` to pull down the dependencies:\n\n```sh\n$ mix deps.get\n```\n\nNow you can make an API call by obtaining an access token and using the\ngenerated modules.\n\n### Obtaining an Access Token\n\n#### Service Accounts\n\nAuthentication is typically done through [Application Default Credentials][adc]\nwhich means you do not have to change the code to authenticate as long as\nyour environment has credentials. Start by creating a\n[Service Account key file][service_account_key_file]. This file can be used to\nauthenticate to Google Cloud Platform services from any environment. To use\nthe file, set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to\nthe path to the key file, for example:\n\n    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json\n\nIf you are deploying to App Engine, Compute Engine, or Container Engine, your\ncredentials will be available by default.\n\n#### OAuth 2.0\n\nMany APIs (like Drive, Gmail, and YouTube) require you to use OAuth 2.0 to\nauthorize requests on behalf of an authenticated user. For an example using\nthe [oauth2-library][oauth2-library], see the [auth sample][auth-sample].\n\nWe've also provided a mix task to fetch a token for testing. The following\ncommand requests a token for the Drive full access scope:\n\n```bash\n$ export GOOGLE_CLIENT_ID=[YOUR-OAUTH-CLIENT-ID]\n$ export GOOGLE_CLIENT_SECRET=[YOUR-OAUTH-CLIENT-SECRET]\n$ mix google_apis.auth https://www.googleapis.com/auth/drive\nOpen the following link in your brower:\nhttps://accounts.google.com/o/oauth2/auth?[some-long-url]\nEnter verification code:\n```\n\nOnce you've logged in and authorized the application, copy the code param from\nthe web browser's url and paste into the console. The script will then fetch\nyour OAuth access token.\n\n```bash\nToken: [your-oauth-token]\n```\n\nYou can then use this token for your testing:\n\n```elixir\nconnection = GoogleApi.Drive.V3.Connection.new(\"your-oauth-token\")\n{:ok, file_list} = GoogleApi.Drive.V3.Api.Files.drive_files_list(conn)\n```\n\n### Making a Request\n\n```ex\n# Obtain an access token using goth\n{:ok, token} = Goth.Token.for_scope(\"https://www.googleapis.com/auth/cloud-platform\")\nconn = GoogleApi.Storage.V1.Connection.new(token.token)\n\n# Call the Storage V1 API (for example) to list buckets\n{:ok, response} = GoogleApi.Storage.V1.Api.Buckets.storage_buckets_list(conn, project_id)\n\n# Print the response\nEnum.each(response.items, \u0026IO.puts(\u00261.id))\n```\n\n### What's Next?\n\nTake a look at our [elixir-samples repository][elixir-samples] repository for\nexamples of calling individual APIs and a getting started tutorial app.\n\n## Generating Clients\n\n### Setup\n\n1. Install nodejs if not already installed.\n1. Install nodejs dependencies:\n\n```bash\n$\u003e npm install\n```\n\n1. Install elixir dependencies:\n\n```bash\n$\u003e mix deps.get\n```\n\nThis project provides 4 mix tasks to componentize the build process:\n\n1. `mix google_apis.discover` - Select which APIs to build\n1. `mix google_apis.fetch` - Download the selected API specifications in Google\n   discovery format\n1. `mix google_apis.convert` - Convert the selected API specifications from\n   Google discovery format to OpenApi v2 (formerly known as Swagger)\n1. `mix google_apis.build` - Generate API clients\n\n### Selecting APIs\n\nThe `mix google_apis.discover` task queries Google's API [discovery\ndirectory][discovery-directory]. The contents of this file are downloaded to a\nstaging file (`api-candidate.json`) under the config directory.\n\nYou can change the name of the file by providing a filename argument to the mix\ntask:\n\n```bash\n$\u003e mix google_apis.discover foo.json\n```\n\nNote that this task is not one that should be run often, as the\n`config/api.json` is considered configuration regarding which APIs to generate.\n\n### Fetching API Specifications\n\nThe `mix google_apis.fetch` task iterates through the list of API\nspecifications in the `config/api.json` file and downloads the specification to\nthe `specifications/gdd` folder with the format of `\u003cname\u003e-\u003cversion\u003e.json`.\n\nYou can limit which APIs to fetch by providing an API name argument to the mix\ntask:\n\n```bash\n$\u003e mix google_apis.fetch CloudTrace\n```\n\n### Converting API Specifications\n\nThe next step is to convert the API specifications from Google's discovery\nformat to OpenApi format.  The `mix google_apis.convert` task iterates through\nthe list of API specifications in the `config/api.json` file and converts each\nfound Google discovery specification to an equivalent* OpenApi version.\n\nYou can configure the converter by modifying the `config/config.exs` setting:\n\n```elixir\nconfig :google_apis, spec_converter: \u003csome converter implementation\u003e\n```\n\nThe default converter uses the node package\n[api-spec-converter][api-spec-converter].  You can also limit which APIs to\nconvert by providing an API name argument to the mix task:\n\n```bash\n$\u003e mix google_apis.convert CloudTrace\n```\n\n### Building API Clients\n\nThe `mix google_apis.build` task iterates through the list of API\nspecifications in the `config/api.json` file and generates an Elixir client\nlibrary in the `clients` folder.\n\nYou can configure the converter by modifying the `config/config.exs` setting:\n\n```elixir\nconfig :google_apis, client_generator: GoogleApis.Generator.SwaggerCli\n```\n\nThe default generator uses Docker and an image based off the [swagger-codegen\nproject][swagger-codegen]. You can further configure this converter by\nmodifying the `config/config.exs` setting:\n\n```elixir\nconfig :google_apis, swagger_cli_image: \"swagger-cli\"\n```\n\nYou can also limit which APIs to generate by providing an API name argument to\nthe mix task:\n\n```bash\n$\u003e mix google_apis.generate CloudTrace\n```\n\n## Contributing\n\nContributions to this library are always welcome and highly encouraged.\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for more information on how to get started.\n\n## License\n\nApache 2.0 - See [LICENSE](LICENSE) for more information.\n\n## Disclaimer\n\nThis is not an officially supported Google product.\n\n[adc]: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow\n[service_account_key_file]: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount\n[discovery-directory]: https://www.googleapis.com/discovery/v1/apis\n[api-spec-converter]: https://github.com/LucyBot-Inc/api-spec-converter\n[swagger-codegen]: https://github.com/swagger-api/swagger-codegen\n[hex_pm]: https://hex.pm/users/google-cloud\n[goth]: https://hex.pm/packages/goth\n[elixir-samples]: https://github.com/GoogleCloudPlatform/elixir-samples\n[oauth2-library]: https://github.com/scrogson/oauth2\n[auth-sample]: https://github.com/GoogleCloudPlatform/elixir-samples/tree/master/auth\n","funding_links":[],"categories":["Third Party APIs","\u003ca name=\"Elixir\"\u003e\u003c/a\u003eElixir"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleapis%2Felixir-google-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogleapis%2Felixir-google-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleapis%2Felixir-google-api/lists"}