Winger O'Shea, 23, joined the Dons as a free agent last summer and scored six goals in 25 appearances during his first season.
Centre-back Flanagan, 20, is one of the club's academy products and also made 25 first-team outings last term.
Speaking to the Dons' official website, O'Shea said: "It's great to be given a new contract. I thought I was doing well before I got injured last season so I knew I had to come back, get fit and prove myself.
"Hopefully now I can have a couple of injury-free seasons and can try and do what I did at the end of the last year."
Flanagan added: "I really enjoyed last season so it's a big relief to be signing and hopefully I can now look forward to two years of playing more football."







