docs: def get_credentials():
    """ Get the credentials to use. We try application credentials first, followed by
        user credentials. The path to the application credentials can be overridden
        by pointing the GOOGLE_APPLICATION_CREDENTIALS environment variable to some file;
        the path to the user credentials can be overridden by pointing the CLOUDSDK_CONFIG
        environment variable to some directory (after which we will look for the file
        $CLOUDSDK_CONFIG/gcloud/credentials). Unless you have specific reasons for
        overriding these the defaults should suffice.
    """
    try:
      credentials, _ = google.auth.default()
      credentials = google.auth.credentials.with_scopes_if_required(credentials, CREDENTIAL_SCOPES)
      return credentials
    except Exception as e:
  
      # Try load user creds from file
      cred_file = get_config_dir() + '/credentials'
      if os.path.exists(cred_file):
        with open(cred_file) as f:
          creds = json.loads(f.read())
        # Use the first gcloud one we find
        for entry in creds['data']:
          if entry['key']['type'] == 'google-cloud-sdk':
            creds = oauth2client.client.OAuth2Credentials.from_json(json.dumps(entry['credential']))
            return _convert_oauth2client_creds(creds)
  
      if type(e) == google.auth.exceptions.DefaultCredentialsError:
        # If we are in Datalab container, change the message to be about signing in.
        if _in_datalab_docker():
          raise Exception('No application credentials found. Perhaps you should sign in.')
  
      raise e