stephenplusplus / google-auto-auth

Making it as easy as possible to authenticate a Google API request
MIT License
34 stars 9 forks source link

80 second delay authorizing a call to Google Cloud Datastore #13

Open bennettrogers opened 7 years ago

bennettrogers commented 7 years ago

I'm just getting started with Google Cloud, and I'm testing out the initial tutorials for Google Cloud DataStore. When trying to make a simple request to fetch a single entity, I'm getting an 80 second delay every time. Through a bit of digging I think I've narrowed it down to something in getAuthClient in google-auto-auth. I'm authenticating my API request the way the tutorial suggests, using gcloud auth application-default login.

Is this a supported way of authenticating? Any ideas what could be causing the delay?

stephenplusplus commented 7 years ago

It's not normal for such a delay-- I've tested very recently and experience almost no lag. The auth step will introduce a small lag for the first request while your credentials are sorted out. What makes you think it's in getAuthClient()? Any specifics will help debug, including environment details, modules/versions, and code.

bennettrogers commented 7 years ago

I was just doing basic console.log debugging to see where the process was hanging, and I was able to trace down to line 47. The delay seems to happen in there somewhere. I'm not that familiar yet with how promises work in javascript, and this line was too complicated for me to continue digging.

As for my environment:

I'm following the getting started guide here, which says to install the Google Cloud SDK first and authenticate with it.

After that authentication step and installing @google-cloud/datastore with Yarn/npm, I just run the simple script in this gist.