title: Sharepoint 2013 Access denied. You do not have permission to perform this action or access this resource. - get_siteGroups()
body: <p>Here is my Javascript code to get all the users from a sharepoint 2013 (office 365). But I get a error what I don't have permissions. Am I missing a trick? </p>
  
  <p>It is used in a sharepoint hosted APP. </p>
  
  <pre><code>    function retrieveAllUsersAllGroups() {
  
      var clientContext = Context;
      this.collGroup = clientContext.get_web().get_siteGroups();
      clientContext.load(collGroup);
      clientContext.load(collGroup, 'Include(Users)');
  
      clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
  }
  
  function onQuerySucceeded() {
  
      var userInfo = '';
  
      var groupEnumerator = collGroup.getEnumerator();
      while (groupEnumerator.moveNext()) {
          var oGroup = groupEnumerator.get_current();
          var collUser = oGroup.get_users();
          var userEnumerator = collUser.getEnumerator();
          while (userEnumerator.moveNext()) {
              var oUser = userEnumerator.get_current();
              this.userInfo += '\nGroup ID: ' + oGroup.get_id() +
                  '\nGroup Title: ' + oGroup.get_title() +
                  '\nUser: ' + oUser.get_title() +
                  '\nLogin Name: ' + oUser.get_loginName();
          }
      }
  
      alert(userInfo);
  }
  
  function onQueryFailed(sender, args) {
  
      alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
  }
  </code></pre>