code: def set_credentials(username, api_key=None, password=None, region=None,
          tenant_id=None, authenticate=True):
      
      global regions, services
      pw_key = password or api_key
      region = _safe_region(region)
      tenant_id = tenant_id or settings.get("tenant_id")
      identity.set_credentials(username=username, password=pw_key,
              tenant_id=tenant_id, region=region, authenticate=authenticate)
      regions = tuple(identity.regions)
      services = tuple(identity.services.keys())
      connect_to_services(region=region)
docs: Set the credentials directly, and then try to authenticate.
  
      If the region is passed, it will authenticate against the proper endpoint
      for that region, and set the default region for connections.