Jesus told people not to work for the food that perishes, but for the food that endures to everlasting life. Their response to that was this,
“What shall we do, that we may work the works of God?” (John 6:28).
Jesus did not deny that they could work the works of God, but said, “This is the work of God, that you believe in Him whom He sent” (John 6:29).
If you believe in Jesus, you are doing the work of God, but that does not mean you are earning your salvation, rather you are simply doing what He said to do.