<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: A second sign is still required after completing an OAuth flow initiated by SessionManager.signIn in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1656774#M21085</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/124928"&gt;@Jianxia&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/184441"&gt;@Wei_Ying&lt;/a&gt;&amp;nbsp;Using the Security options count as canceling the login popup and trigger the affects documented by &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2564"&gt;@RyanTaylor&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffreyThompson2_0-1760033844100.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141700i6579508DBE5F4442/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffreyThompson2_0-1760033844100.png" alt="JeffreyThompson2_0-1760033844100.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Oct 2025 18:18:21 GMT</pubDate>
    <dc:creator>JeffreyThompson2</dc:creator>
    <dc:date>2025-10-09T18:18:21Z</dc:date>
    <item>
      <title>A second sign in prompt is still shown after completing an OAuth flow initiated by SessionManager.signIn</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1656762#M21084</link>
      <description>&lt;P&gt;We developed an Experience Builder Dev Edition 1.17 experience that we deploy to our own web server, e.g., &lt;A href="https://example.com/exb" target="_blank" rel="noopener"&gt;https://example.com/exb&lt;/A&gt;&amp;nbsp;with our Enterprise 11.3 portal at &lt;A href="https://example.com/portal" target="_blank" rel="noopener"&gt;https://example.com/portal&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We require that the user sign in to the application immediately, before any widgets are rendered and before they attempt to send HTTP/REST requests to any out of the box or custom services and rest apis. I.e., the out of the box "sign in when first accessing a protected resource" happens much too late in the worfklow for our custom services.&lt;/P&gt;&lt;P&gt;To that end we've implemented an app extension using&amp;nbsp;APP_CONFIG_PROCESSOR that is called very early in the app startup. The extension calls SessionManager.signIn to initiate an OAuth flow against Enterprise Portal. (See the code at bottom for implementation details).&lt;/P&gt;&lt;P&gt;However, we've run into a couple issues.&lt;/P&gt;&lt;P&gt;P1. Running locally: The extension is not executed on a soft refresh.&lt;/P&gt;&lt;P&gt;When running everything locally via Experience Builder dev edition (i.e., npm run start) I've recently found that that extension code is not run on a soft refresh of the application (i.e., F5) however it is run on a hard refresh (CTRL-F5). If the extension code is not run I'm unable to set the token for some our our services and our widgets fail.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Q1. Shouldn't the extension point run regardless soft or hard page refreshes?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;P2. Running the deployed app: Second out of the box sign prompt persists&lt;/P&gt;&lt;P&gt;When running the deployed application, after the user logs in via our initiated flow the application reloads and the user is prompted with a second out of the box sign in dialog. If they choose to sign in, they do so via a popup, and most things work. If they choose to cancel the sign in, the map and other widgets fail due to an invalid session/token/something else.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Q2. How do we initiate a sign in flow that fully signs in the user such that no subsequent sign prompts are required? Is SessionManager.signIn() insufficient?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Here is the code.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// extensions/login.ts

export default class Login implements extensionSpec.AppConfigProcessorExtension
{
  id = "my-awesome-login";
  widgetId: string;

  async process(appConfig: AppConfig): Promise&amp;lt;AppConfig&amp;gt; {
    try {
      await signIn("&amp;lt;myportal&amp;gt;", "myclientid");
      return Promise.resolve(appConfig);
    } catch (err) {
      console.error(err);
      return Promise.resolve(appConfig);
    }
  }
}

export async function signIn(portalUrl: string, clientId) {
  const sm = SessionManager.getInstance();
  const mainSession = sm?.getMainSession();
  const user = await mainSession?.getUser();

  const loggedIn = !!mainSession &amp;amp;&amp;amp; !!user;

  if (!loggedIn) {
    const userSession = await sm.signIn({
      popup: false,
      desUrl: portalUrl,
      clientId: clientId,
      fromUrl: window.location.href,
      forceLogin: true,
    });

    // when popup is false the following code is unreachable
    // as the window refreshes to sign the user but is left
    // in place in case we want to turn popup: true

    // Set private _token variable in Usage Tracking Module
    setUsageToken(userSession.token);
  } else {
    // Set private _token variable in Usage Tracking Module
    setUsageToken((userSession.token);
  }
}&lt;/LI-CODE&gt;&lt;P&gt;cc &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/109676"&gt;@JunshanLiu&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 17:16:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1656762#M21084</guid>
      <dc:creator>RyanTaylor</dc:creator>
      <dc:date>2025-10-16T17:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: A second sign is still required after completing an OAuth flow initiated by SessionManager.signIn</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1656774#M21085</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/124928"&gt;@Jianxia&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/184441"&gt;@Wei_Ying&lt;/a&gt;&amp;nbsp;Using the Security options count as canceling the login popup and trigger the affects documented by &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2564"&gt;@RyanTaylor&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffreyThompson2_0-1760033844100.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141700i6579508DBE5F4442/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffreyThompson2_0-1760033844100.png" alt="JeffreyThompson2_0-1760033844100.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 18:18:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1656774#M21085</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2025-10-09T18:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: A second sign is still required after completing an OAuth flow initiated by SessionManager.signIn</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1657178#M21101</link>
      <description>&lt;P&gt;Thanks for the post. I am using Experience Builder 1.17 and this does not seem to be available to me. I updated my post to reflect the version number.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2025 18:42:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1657178#M21101</guid>
      <dc:creator>RyanTaylor</dc:creator>
      <dc:date>2025-10-10T18:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: A second sign in prompt is still shown after completing an OAuth flow initiated by SessionManager.signIn</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1666448#M21667</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/243454"&gt;@XiaodongWang&lt;/a&gt;&amp;nbsp;any idea?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 19:51:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1666448#M21667</guid>
      <dc:creator>Wei_Ying</dc:creator>
      <dc:date>2025-11-17T19:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: A second sign in prompt is still shown after completing an OAuth flow initiated by SessionManager.signIn</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1674606#M22018</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2564"&gt;@RyanTaylor&lt;/a&gt;, Thank you for being patient with us. The team has performed the following tests. Unfortunately, we are unable to reproduce the problem on our side.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Tested with dev1.19 - issue cannot be reproduced in either the builder environment or the deployed environment.&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Tested with dev1.17 - issue cannot be reproduced in either&amp;nbsp;the builder environment or the deployed environment.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Tested with the app built with v1.17 and deployed to the same web server hosting the portal 12.0 - issue cannot be reproduced.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Please let us know if there is something we missed.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Dec 2025 22:45:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/a-second-sign-in-prompt-is-still-shown-after/m-p/1674606#M22018</guid>
      <dc:creator>Jianxia</dc:creator>
      <dc:date>2025-12-22T22:45:20Z</dc:date>
    </item>
  </channel>
</rss>

