Goth.Token change for_scope function

Hello,

I saw that the function Goth.Token.for_scope is deprecated, can you please help me with the equivalent config for the function Goth.Token.fetch(config), my current config is :

Goth.Token.for_scope("https://www.googleapis.com/auth/cloudkms")

Many thanks

Hello, any experiences with Goth ?

Have you tried the steps in the upgrade guide?

Hi @al2o3cr ,

I’m using Goth in an elixir Library that do some stuff and return a result. Now in my implementation, the apps that will install the lib will only configure the env variable :

# config/config.exs
config :goth,
  json: {:system, "GCP_CREDENTIALS"}

but in the guide, the configuration is done in the MyApp.Application file and we will name the module :

children = [
      {Goth, name: MyApp.Goth, source: source}
    ]

Do you have any suggestion how can I upgrade the Goth module in a lib ? first sight, I think that all the applications that will install my lib must configure their start() function and I must use a general name for the module : {Goth, name: General.Goth, source: source} to use that later in the lib as :

  def gcloud_authorization() do
    {:ok, token} = Goth.fetch(General.Goth)
    "#{token.type} #{token.token}"
  end

What do you think ? Because ike that I will be limited in terms of scope, because the apps may use Goth for other purposes and not only the scope that the lib will use.

You can take a look at this issue and my accompanying PR. I need to finish it to support backwards compatibility.

Hopefully the library isn’t supervising its own Goth process, as in my experience that’s a little more difficult to unwind without breaking things

If you’re running on Google Cloud I’ve found the only thing that doesn’t support the metadata generated server token is obviously signing urls for cloud storage, since it’s not a private key, just a token.

But if you’re already using a service account JSON it should be just swapping the calls, configuring the library to take a name, and starting your MyApp.Goth before any process that will depend on it.