Acting meanly after a disappointment.
In the fable The Fox and the Grapes, which is attributed to the ancient Greek writer Aesop, the fox isn't able to reach the grapes and declares them to be sour:
Harrison Weir's 1884 English translation, which claims to be "from original sources ", presents the text like this:
A famished Fox saw some clusters of ripe black grapes hanging from a trellised vine. She resorted to all her tricks to get at them, but wearied herself in vain, for she could not reach them. At last she turned away, beguiling herself of her disappointment, and saying: "The Grapes are sour, and not ripe as I thought."
Some of the fables associated with Aesop were written as late as 1900 and many of the earlier ones were considerably amended in Victorian translation into English. Also, some scholars also prefer 'unripe' to 'sour' as a literal translation of the earlier Greek texts.
The phrase also occurs in the Bible, Ezekiel - in Miles Coverdale's Bible, 1535:
18:1 The worde of the LORDE came vnto me, on this maner:
18:2 What meane ye by this comon prouerbe, that ye vse in the londe of Israel, sayenge: The fathers haue eaten soure grapes, and the childres teth are set on edge?
18:3 As truly as I lyue, saieth ye LORDE God, ye shal vse this byworde nomore in Israel.
The difficulty in dating Aesop's work makes it uncertain whether it first entered the English language via the Fables or via the Bible.