peburrows / goth

Elixir package for Oauth authentication via Google Cloud APIs
http://hexdocs.pm/goth
MIT License
284 stars 108 forks source link

Suggestion for scope parameter #97

Closed sam701 closed 3 years ago

sam701 commented 3 years ago

The Goth's source parameters has a field scope. That is a string but actually it can contain multiple scopes separated by a single space. The code below works:

    source = {
      :service_account, credentials,
      scope: "https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.compose",
      sub: "user1@abc.org"
    }
    children = [{Goth, name: :my_goth, source: source}]
    {:ok, _} = Supervisor.start_link(children, strategy: :one_for_one)

It would be nice if the scope becomes scopes and expects a list of strings. Because

wojtekmach commented 3 years ago

Sounds good. A PR that changes the :scope option to :scopes for the :service_account source would be appreciated. I think we should still keep it as :scope (string) on the %Goth.Token{} struct for backwards compatibility though.