ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - peburrows/goth: Elixir package for Oauth authentication via Google Cloud APIs
Elixir package for Oauth authentication via Google Cloud APIs - peburrows/goth
Visit Site

GitHub - peburrows/goth: Elixir package for Oauth authentication via Google Cloud APIs

GitHub - peburrows/goth: Elixir package for Oauth authentication via Google Cloud APIs

Goth

CI

Google + Auth = Goth

A simple library to generate and retrieve OAuth2 tokens for use with Google Cloud Service accounts.

Installation

Note: below are instructions for using Goth v1.3+. For more information on earlier versions of Goth, see v1.2.0 documentation on hexdocs.pm.

  1. Add :goth to your list of dependencies in mix.exs.

    def deps do
      [
        {:goth, "~> 1.4"}
      ]
    end
    
  2. Add Goth to your supervision tree:

    defmodule MyApp.Application do
      use Application
    
      def start(_type, _args) do
        credentials =
          "GOOGLE_APPLICATION_CREDENTIALS_JSON"
          |> System.fetch_env!()
          |> Jason.decode!()
    
        source = {:service_account, credentials}
    
        children = [
          {Goth, name: MyApp.Goth, source: source}
        ]
    
        Supervisor.start_link(children, strategy: :one_for_one)
      end
    end
    

    If you set GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_APPLICATION_CREDENTIALS_JSON, have a ~/.config/gcloud/application_default_credentials.json file, ~/.config/gcloud/configurations/config_default file or deploy your application to Google Cloud, you can omit the :source option:

    def start(_type, _args) do
      children = [
        {Goth, name: MyApp.Goth}
      ]
    
      Supervisor.start_link(children, strategy: :one_for_one)
    end
    

    If you want to use multiple credentials, you may consider doing:

    def start(_type, _args) do
      Supervisor.start_link(servers(), strategy: :one_for_one)
    end
    
    defp servers do
      servers = [
        {MyApp.Cred1, source1},
        ...
        {MyApp.CredN, source2}
      ]
    
      for {name, source} <- servers do
        Supervisor.child_spec({Goth, name: name, source: source}, id: name)
      end
    end
    
  3. Fetch the token:

    iex> Goth.fetch!(MyApp.Goth)
    %Goth.Token{
      expires: 1453356568,
      token: "ya29.cALlJ4ICWRvMkYB-WsAR-CZnExE459PA7QPqKg5nei9y2T9-iqmbcgxq8XrTATNn_BPim",
      type: "Bearer",
      ...
    }
    

See Goth.start_link/1 for more information about possible configuration options.

Upgrading from Goth 1.2

See Upgrading from Goth 1.2 guide for more information.

Community resources

Copyright and License

Copyright (c) 2016 Phil Burrows

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory