Make :goth option optional
wojtekmach opened this issue · comments
A user may already have a token from another place. Here's one easy way to grab it:
$ gcloud auth application-default print-access-token
ya29.a0...
If a user already has access to a token, it is unnecessary for them to go through Goth, they can set the auth: {:bearer, token}
on their req instead. For us, this can remove a ton of boilerplate from our unit tests. We should have one unit test where we do use Goth though. In integration tests we should use it too.
What if we use this function so they could start Req
with auth
already set?
defp auth(%{auth: auth}), do: auth
defp auth(%{goth: goth}), do: {:bearer, Goth.fetch!(goth).token}
I wouldn't worry about this. If someone has this use case, then they can open an issue/PR to better discuss it.