The Torah says, “And Hashem was with Yosef, and he was a successful man.” The usual reading is that Yosef felt Hashem was with him. the Ketav Sofer explained that Yosef was a slave in Mitzrayim, accused and in prison, and every day he said, I will succeed, and Hashem was with that determination.