<?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 How can I pass IdentifyManager credentials to a Calcite avatar? in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-can-i-pass-identifymanager-credentials-to-a/m-p/1276700#M6667</link>
    <description>&lt;P&gt;I'm new to Experience builder dev edition and I've been attempting to create some simple widgets using Calcite.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've been error handling by outputting the error to text beside my avatar.&amp;nbsp; I would like to grab the thumbnail and user name from Esri's Identity manager&lt;BR /&gt;&lt;BR /&gt;I'm signed in through portal.&amp;nbsp; However, it is displaying this error.&amp;nbsp; I've also tried it through AGO.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohnPhillipsGeo_0-1680898962831.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67528i7F9CFD5330289EB0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohnPhillipsGeo_0-1680898962831.png" alt="JohnPhillipsGeo_0-1680898962831.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Any advice would be much appreciated!&lt;BR /&gt;&lt;BR /&gt;My widget.tsx file:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import React, { useState, useEffect } from 'react';
import { AllWidgetProps } from 'jimu-core';
import { CalciteAvatar } from 'calcite-components';
import esriConfig from '@arcgis/core/config';
import IdentityManager from '@arcgis/core/identity/IdentityManager';
import Portal from '@arcgis/core/portal/Portal';

const Widget = (props: AllWidgetProps&amp;lt;any&amp;gt;) =&amp;gt; {
  const [thumbnailUrl, setThumbnailUrl] = useState('');
  const [fullName, setFullName] = useState('');
  const [error, setError] = useState('');

  useEffect(() =&amp;gt; {
    // Set the ArcGIS portal URL
    esriConfig.portalUrl = 'https://myorg.maps.arcgis.com';

    // Check if the user is signed in to ArcGIS Online
    IdentityManager.checkSignInStatus(esriConfig.portalUrl + '/sharing')
      .then((credential) =&amp;gt; {
        if (credential) {
          // Get the user's Portal object
          const portal = new Portal({ url: esriConfig.portalUrl });
          portal.load().then(() =&amp;gt; {
            // Get the user's thumbnail URL from the portal user object
            const thumbnail = portal.user &amp;amp;&amp;amp; portal.user.thumbnailUrl;
            // Set the thumbnail URL in the state
            setThumbnailUrl(thumbnail);
            // Set the full name in the state
            setFullName(portal.user.fullName);
          });
        } else {
          setError('User not signed in');
        }
      })
      .catch((error) =&amp;gt; {
        console.error('Error checking sign-in status:', error);
        setError(error.message);
      });
  }, []);

  return (
    &amp;lt;div style={{ display: 'flex', alignItems: 'center' }}&amp;gt;
      &amp;lt;CalciteAvatar thumbnail={thumbnailUrl} scale="m" /&amp;gt;
      &amp;lt;span style={{ marginLeft: '10px' }}&amp;gt;{error || fullName}&amp;lt;/span&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Widget;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2023 20:23:52 GMT</pubDate>
    <dc:creator>JohnPhillipsGeo</dc:creator>
    <dc:date>2023-04-07T20:23:52Z</dc:date>
    <item>
      <title>How can I pass IdentifyManager credentials to a Calcite avatar?</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/how-can-i-pass-identifymanager-credentials-to-a/m-p/1276700#M6667</link>
      <description>&lt;P&gt;I'm new to Experience builder dev edition and I've been attempting to create some simple widgets using Calcite.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've been error handling by outputting the error to text beside my avatar.&amp;nbsp; I would like to grab the thumbnail and user name from Esri's Identity manager&lt;BR /&gt;&lt;BR /&gt;I'm signed in through portal.&amp;nbsp; However, it is displaying this error.&amp;nbsp; I've also tried it through AGO.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohnPhillipsGeo_0-1680898962831.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67528i7F9CFD5330289EB0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohnPhillipsGeo_0-1680898962831.png" alt="JohnPhillipsGeo_0-1680898962831.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Any advice would be much appreciated!&lt;BR /&gt;&lt;BR /&gt;My widget.tsx file:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import React, { useState, useEffect } from 'react';
import { AllWidgetProps } from 'jimu-core';
import { CalciteAvatar } from 'calcite-components';
import esriConfig from '@arcgis/core/config';
import IdentityManager from '@arcgis/core/identity/IdentityManager';
import Portal from '@arcgis/core/portal/Portal';

const Widget = (props: AllWidgetProps&amp;lt;any&amp;gt;) =&amp;gt; {
  const [thumbnailUrl, setThumbnailUrl] = useState('');
  const [fullName, setFullName] = useState('');
  const [error, setError] = useState('');

  useEffect(() =&amp;gt; {
    // Set the ArcGIS portal URL
    esriConfig.portalUrl = 'https://myorg.maps.arcgis.com';

    // Check if the user is signed in to ArcGIS Online
    IdentityManager.checkSignInStatus(esriConfig.portalUrl + '/sharing')
      .then((credential) =&amp;gt; {
        if (credential) {
          // Get the user's Portal object
          const portal = new Portal({ url: esriConfig.portalUrl });
          portal.load().then(() =&amp;gt; {
            // Get the user's thumbnail URL from the portal user object
            const thumbnail = portal.user &amp;amp;&amp;amp; portal.user.thumbnailUrl;
            // Set the thumbnail URL in the state
            setThumbnailUrl(thumbnail);
            // Set the full name in the state
            setFullName(portal.user.fullName);
          });
        } else {
          setError('User not signed in');
        }
      })
      .catch((error) =&amp;gt; {
        console.error('Error checking sign-in status:', error);
        setError(error.message);
      });
  }, []);

  return (
    &amp;lt;div style={{ display: 'flex', alignItems: 'center' }}&amp;gt;
      &amp;lt;CalciteAvatar thumbnail={thumbnailUrl} scale="m" /&amp;gt;
      &amp;lt;span style={{ marginLeft: '10px' }}&amp;gt;{error || fullName}&amp;lt;/span&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Widget;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 20:23:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/how-can-i-pass-identifymanager-credentials-to-a/m-p/1276700#M6667</guid>
      <dc:creator>JohnPhillipsGeo</dc:creator>
      <dc:date>2023-04-07T20:23:52Z</dc:date>
    </item>
  </channel>
</rss>

