How to connect existing node group in a material in Phyton?
Here:
            #link input and output of group
            material.node_tree.links.new(bakeGroup.outputs['shaderIn'], mainShader.outputs[0])
            material.node_tree.links.new(material_output.inputs[0], bakeGroup.inputs['shaderOut'])

bakeGroup is a NodeGroup. You want to use the Group Node dummy_group_node.
Also remember in links.new(A, B), A is the input socket, and B is the output socket.
So do this instead:
            #link input and output of group
            material.node_tree.links.new(dummy_group_node.inputs['shaderIn'], mainShader.outputs[0])
            material.node_tree.links.new(material_output.inputs[0], dummy_group_node.outputs['shaderOut'])