peburrows / goth

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

Bearer token construction #108

Closed nbernardes closed 2 years ago

nbernardes commented 3 years ago

Hey! When requesting for the access token of a google service account JSON file I have in my project I get a strange bearer token construction. With this behaviour the token still works, but it's strange to just give this output.

def get_authorization_token(scope \\ default_scopes()) do
    case Token.for_scope(scope) do
      {:ok, %Goth.Token{token: token, type: type}} ->
        {:ok, {"authorization", "#{type} #{token}"}}

      _ ->
        {:error, :authorization_code}
    end
end

When calling the function, I get the following:

iex(1)> Google.Auth.get_authorization_token
{:ok, {"authorization", "Bearer ya29.c.Kq{token}bE...{an absurd repetition of dots 😂}..."}}
wojtekmach commented 2 years ago

Could you clarify what is strange? What did you expect to happen and what actually happened?

wojtekmach commented 2 years ago

oh, you are saying a ton of dots is weird? Yeah it's weird but that's what we get from the server and I don't think we should mess with it!

nbernardes commented 2 years ago

Oh ok @wojtekmach

Yeah even with the dots it still works so yeah it's best to just don't mess with it, i was just to give your attention if it was the case that it was on your side the problem ;)