code: def get_oauth2_credentials(self):
      creds = None
  
      if self.credentials_file or self.credentials_url:
          # get the current directory and checks tokens & creds
          curr_dir = self.handler_storage.folder_get("config")
  
          creds_file = os.path.join(curr_dir, "creds.json")
          secret_file = os.path.join(curr_dir, "secret.json")
  
          if os.path.isfile(creds_file):
              creds = Credentials.from_authorized_user_file(
                  creds_file, self.scopes
              )
  
          if not creds or not creds.valid:
              logger.debug(
                  "Credentials do not exist or are invalid, attempting to authorize again"
              )
  
              if self._download_secret_file(secret_file):
                  # save to storage
                  self.handler_storage.folder_sync("config")
              else:
                  raise ValueError(
                      "No valid Gmail Credentials filepath or S3 url found."
                  )
  
              if creds and creds.expired and creds.refresh_token:
                  creds.refresh(Request())
                  logger.debug("Credentials refreshed successfully")
              else:
                  creds = self._execute_google_auth_flow(
                      secret_file, self.scopes, self.code
                  )
                  logger.debug("New credentials obtained")
  
              self._save_credentials_to_file(creds, creds_file)
              logger.debug(f"saved session credentials to {creds_file}")
              self.handler_storage.folder_sync("config")
  
      return creds
  
file_path: mindsdb/mindsdb/integrations/handlers/utilities/auth_utilities/google/google_oauth_utilities.py
imports: import os
  import json
  import requests
  import datetime
  from flask import request
  from shutil import copyfile
  from mindsdb.utilities import log
  from ..exceptions import AuthException
  from google_auth_oauthlib.flow import Flow
  from google.oauth2.credentials import Credentials
  from google.auth.transport.requests import Request
label_desc: Use image node_id 2 for calling the GoogleOAuth2Manager obj's underlying member method code with example usage: obj.get_oauth2_credentials() and returns: creds