This sounds like a use case for Macaroons [1]. A primer and a public implementation can be found here [2]. There's also a JavaScript implementation [3].
[1] http://research.google.com/pubs/pub41892.html
[2] http://hackingdistributed.com/2014/05/16/macaroons-are-bette...