I have created a Web Mapping Javascript Application in Portal that points to a Javascript Application which runs on an different VM than ArcGIS Enterprise (Esri Portal and Server are on Windows Machines, VM is on Linux - all in the same Azure DMZ). We are using a NGINX webserver on the Linux VM for publishing the JS App - portal, server and the Nginx are behind the same Gateway - all in the same domain.
I am using the IdentityManager to register the OAuthInfos, then I check if the user is already signed in using the checkSignInStatus Method. If not credentials are requested using getCredentials. When calling the self method "<our domain>/portal/sharing/rest/community/self?f=json&token=<the token>" I can see the correct appId in the appInfo property which is the same I used for the OAuthInfos.
This works fine as long as I am not logged in the portal and I am directly opening the Web App in the browser (pointing to the url). But when I am already logged into the portal and I open the application from the Web Mapping Javascript Application Item, my JS App wont open the OAuth Dialog again (which is correct, because I am already logged in from the portal) - but when I call "<our domain>/portal/sharing/rest/community/self?f=json&token=<the token>" now, the appId value in the appInfo Property is "arcgisonline".
How can I register my JS App - create a new token?