All Projects → peburrows → Goth

peburrows / Goth

Licence: mit
Elixir package for Oauth authentication via Google Cloud APIs

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Goth

Cloud Functions Go
Unofficial Native Go Runtime for Google Cloud Functions
Stars: ✭ 427 (+123.56%)
Mutual labels:  gcp, google-cloud-platform, google
Unity Solutions
Use Firebase tools to incorporate common features into your games!
Stars: ✭ 95 (-50.26%)
Mutual labels:  gcp, google-cloud-platform
Capacitorgoogleauth
Capacitor plugin for Google Auth. Lightweight & no dependencies.
Stars: ✭ 92 (-51.83%)
Mutual labels:  google, authentication
Gcpsketchnote
If you are looking to become a Google Cloud Engineer , then you are at the right place. GCPSketchnote is series where I share Google Cloud concepts in quick and easy to learn format.
Stars: ✭ 2,631 (+1277.49%)
Mutual labels:  gcp, google-cloud-platform
Runtimes Common
Common tools used by the GCP runtimes.
Stars: ✭ 86 (-54.97%)
Mutual labels:  gcp, google
Gargle
Infrastructure for calling Google APIs from R, including auth
Stars: ✭ 88 (-53.93%)
Mutual labels:  google, authentication
Functions Samples
Collection of sample apps showcasing popular use cases using Cloud Functions for Firebase
Stars: ✭ 10,576 (+5437.17%)
Mutual labels:  google-cloud-platform, google
Google Cloud Eclipse
Google Cloud Platform plugin for Eclipse
Stars: ✭ 75 (-60.73%)
Mutual labels:  google-cloud-platform, google
Gsts
Obtain and store AWS STS credentials to interact with Amazon services by authenticating via G Suite SAML.
Stars: ✭ 136 (-28.8%)
Mutual labels:  google, authentication
Gcp Data Engineer Exam
Study materials for the Google Cloud Professional Data Engineering Exam
Stars: ✭ 144 (-24.61%)
Mutual labels:  gcp, google-cloud-platform
Googleauthr
Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
Stars: ✭ 150 (-21.47%)
Mutual labels:  google, authentication
Cloudprober
An active monitoring software to detect failures before your customers do.
Stars: ✭ 1,269 (+564.4%)
Mutual labels:  gcp, google
Svelte Social Auth
Social Auth for Svelte v3
Stars: ✭ 86 (-54.97%)
Mutual labels:  google, authentication
Gimme
Creating time bound IAM Conditions with ease and flair
Stars: ✭ 92 (-51.83%)
Mutual labels:  gcp, google-cloud-platform
Fog Google
Fog for Google Cloud Platform
Stars: ✭ 83 (-56.54%)
Mutual labels:  gcp, google-cloud-platform
Awesome Gcp Certifications
Google Cloud Platform Certification resources.
Stars: ✭ 1,328 (+595.29%)
Mutual labels:  gcp, google-cloud-platform
Turnstile
An authentication framework for Swift.
Stars: ✭ 163 (-14.66%)
Mutual labels:  google, authentication
Googleclientplugin
Google Client Plugin for Xamarin iOS and Android
Stars: ✭ 69 (-63.87%)
Mutual labels:  google, authentication
Forseti Security
Forseti Security
Stars: ✭ 1,179 (+517.28%)
Mutual labels:  gcp, google-cloud-platform
Gcp Service Broker
Open Service Broker for Google Cloud Platform
Stars: ✭ 133 (-30.37%)
Mutual labels:  gcp, google-cloud-platform

CI

Goth

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. To use the built-in, Hackney-based HTTP client adapter, add :hackney too:

    def deps do
      [
        {:goth, "~> 1.3-rc"},
        {:hackney, "~> 1.17"}
      ]
    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
    
  3. Fetch the token:

    iex> {:ok, token} = Goth.fetch(MyApp.Goth)
    iex> token
    %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.3

Earlier versions of Goth relied on global application environment configuration which is deprecated in favour of a more direct and explicit approach in Goth v1.3+. Previously, we were depending on the HTTPoison HTTP client, now we have an optional dependency on Hackney, so in order to use it, you need to explicitly include it in your dependencies too:

Change your mix.exs:

def deps do
 [
   {:goth, "~> 1.3-rc"},
   {:hackney, "~> 1.17"}
 ]
end

You might have code similar to this:

# config/config.exs
config :goth,
  json: {:system, "GCP_CREDENTIALS"}
# lib/myapp.ex
defmodule MyApp do
  def gcloud_authorization() do
    {:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform.read-only")
    "#{token.type} #{token.token}"
  end
end

Replace it with:

defmodule MyApp.Application do
  @moduledoc false
  use Application

  def start(_type, _args) do
    credentials = "GCP_CREDENTIALS" |> 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
# lib/myapp.ex
defmodule MyApp do
  def gcloud_authorization() do
    {:ok, token} = Goth.fetch(MyApp.Goth)
    "#{token.type} #{token.token}"
  end
end

For more information on earlier versions of Goth, see v1.2.0 documentation on hexdocs.pm.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].