I have been successful in getting the portal user in a widget developed using WAB developer version v1.0 . Below is code snippet to get the portal user.
"this.portal = portalUtils.getPortal(this.appConfig.portalUrl);
var username = this.portal.user.username;"
I am able to get the the current portal username when I debug the widget. I am even able to get the portal username when I launch it through web app builder app url.
The issue is when download the code and deploy it in IIS. The application throws the error and the username is undefined . On further debugging what I could find is the application is not able get the portal username.
Any guidance on issue would be great.
When open builder, user has to sign in, so you can get user info. But if the app is deployed in other web server, user is not signed in unless a private resource is requested. So, if you want to get user info in app that deployed in other web server, you can create a widget, which has the login feature .