Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the README and sample code for initialising auth token still correct? #4

Open
tunniclm opened this issue Dec 6, 2021 · 0 comments

Comments

@tunniclm
Copy link

tunniclm commented Dec 6, 2021

We have been integrating Google Business Messages into our application and have been using the Quick Start document and Samples as a guide on how to authenticate with the APIs.

We noticed that the guide uses the following code for initialising the auth token:

async function initCredentials() {
  authClient = await auth.getClient();

  // Initialize auth token
  authClient.refreshAccessToken();
  await authClient.getAccessToken();
}

Referring to the API documentation for the google-auth-library, we noticed that refreshAccessToken() is an async function and wondered whether we should be awaiting the call in our initialisation code.

After some research we also wondered whether the call to refreshAccessToken() is still necessary since there are several threads suggesting that it may no longer be needed (along with it being deprecated, then subsequently undeprecated again).

Here are some links to the relevant threads/documents:

Therefore, my question is whether or not the Quick Start guide and sample are still correct or is there a potential race condition or other issue with the token initialisation code?

If we should be using await or replacing refreshAccessToken() with something else, then what does that code look like and can the Quick Start guide and sample be updated?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant