We have developed a redline tool in WAB for a client that creates objects in feature classes through a feature service. It all works great, until we put it on the client machine where we have proxy set up with AGOL to do the authentication. I've tracked down in F12 tools that the offending line of javascript is creating a function to handle the promise returned from a portal object's 'load' function, so that we can get a list of the groups the user has access to (see below).
Without using the proxy for the WAB app, it works perfectly and flows through the .then functions as expected - but the users are forced to log in a second time when the open the app from AGOL. If I configure the proxy to handle this app, the app itself will load and run fine (maps display, etc), but when the widget is opened, a generic javascript syntax error with no indication of source line is thrown. The error occurs when stepping through when the on(aPortal, load... is executed.
Is there a different method for accessing the user's AGOL groups that needs to be used in cases where a proxy is set up for the app? I've tried adding the portal url to the proxy.config (which seemed like cirucular logic anyhow) but that did not change things at all.
on(aPortal, "load", function(p) {
p.signIn().then(function() {
var aUser = p.getPortalUser();
myself._username = aUser.username;
var searchParams = {
q: "orgid:" + p.getPortalUser().orgId,
num: 100,
sortField: "title"
};
p.queryGroups(searchParams).then(function(data) {
var aGroup = null;
//
// Populate the group map.
//
for (var i in data.results) {
aGroup = data.results;
myself._groupIdNameMap[aGroup.id] = aGroup.title;
}
myself._buildGroupVisibilityControl();
});
});
});
Thanks in advance,
Mikkel