peburrows / goth

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

403 Forbidden whenever I try to make a token #64

Closed vans163 closed 5 years ago

vans163 commented 5 years ago

I transferred the GCP JSON credentials to another system.

{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
peburrows commented 5 years ago

I'm gonna need more information than that; a 403 could mean a number of different things.

peburrows commented 5 years ago

Do your credentials work on the system you transferred them from?

vans163 commented 5 years ago

Yes. creds work fine on that system, i just transferred the project over and did a icloud sdk installation jst incase.

The ERTS and elixir versions are different. I am thinking maybe something is wonky. Testing more ATM..

Copied everything over to another system and it works.. testing more

Exact same code inside a different app

{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
** (MatchError) no match of right hand side value: {:error, {:invalid, "<", 0}}
    (goth) lib/goth/token.ex:67: Goth.Token.from_response_json/3
    (goth) lib/goth/client.ex:54: Goth.Client.get_access_token/3
    (goth) lib/goth/token.ex:100: Goth.Token.retrieve_and_store!/2

(the < error means its sending back the 403 forbidden)

Exact same app copied to a different system

{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
{:ok,
 %Goth.Token{
   expires: 1565430969,
   scope: "https://www.googleapis.com/auth/cloud-platform",
   sub: nil,
   token: "ya29.c.ElpgefafeefaaefafeaeffeaZG5j5mc2lYGDI",
   type: "Bearer"
 }}

The mix.lock files are exactly the same.

vans163 commented 5 years ago

Holy shit i never use config files. its had to be called config.exs not config.ex! Possibly add an error if the config file :gothjson is not set right?