Get the access_token? of google Oauth2

after running python library, with Google api installed, I reported a connection timeout error. Is my agent not set up properly? But it"s okay for me to go to google? I use pycharm

from oauth2client.service_account import ServiceAccountCredentials
fsm_scope = "https://www.googleapis.com/auth/firebase.messaging"


def _get_access_token():
  """Retrieve a valid access token that can be used to authorize requests.

  :return: Access token.
  """
  credentials = ServiceAccountCredentials.from_json_keyfile_name(
      "service-account.json", fsm_scope)
  access_token_info = credentials.get_access_token()
  return access_token_info.access_token

_get_access_token()

error message:
TimeoutError: [WinError 10060] the connection attempt failed because the connecting party did not reply correctly or the connected host did not respond after a period of time.

Mar.13,2021
If

times out, you can't connect. Just like you can't connect to Google, try changing the suffix to cn. After all, some Google services can already be accessed in China, such as http://ditu.google.cn.


network problems. I don't have this problem when I run the python script on the test server

.
Menu