code: def _get_gce_credentials(request=None):
      
      # Ping requires a transport, but we want application default credentials
      # to require no arguments. So, we'll use the _http_client transport which
      # uses http.client. This is only acceptable because the metadata server
      # doesn't do SSL and never requires proxies.
  
      # While this library is normally bundled with compute_engine, there are
      # some cases where it's not available, so we tolerate ImportError.
      try:
          from google.auth import compute_engine
          from google.auth.compute_engine import _metadata
      except ImportError:
          return None, None
  
      if request is None:
          request = google.auth.transport._http_client.Request()
  
      if _metadata.ping(request=request):
          # Get the project ID.
          try:
              project_id = _metadata.get_project_id(request=request)
          except exceptions.TransportError:
              project_id = None
  
          return compute_engine.Credentials(), project_id
      else:
          return None, None
docs: Gets credentials and project ID from the GCE Metadata Service.