I am trying to follow the exact example code from
http://msdn.microsoft.com/en-us/library/office/jj246414(v=office.15).aspx
to get it work in an app web. I execute the code from console within app web, so there should be no cross domain issues. I get the error "Access denied. You do not have permission to perform this action or access this resource" although i am a site owner. Any ideas?