<?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 Oauth 2.0 Sign in in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/oauth-2-0-sign-in/m-p/1295139#M6625</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have an old web map, created in C#, that utilizes the ArcGIS API for JavaScript 3. Currently, there is a proxy used to log into the organizational account to utilize the web map. I am attempting to update the code to use Oauth to sign into the ArcGIS Enterprise account instead.&lt;/P&gt;&lt;P&gt;Things work until it checks if the user is signed in, which is false. I'm currently getting an error with the domStyle panels (Cannot read properties of null (reading 'style')).&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks, tad&lt;/P&gt;&lt;P&gt;Here is the code (apologies for non-formatted):&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;"dojo/dom",&lt;BR /&gt;"dojo/parser",&lt;BR /&gt;"esri/arcgis/Portal",&lt;BR /&gt;"esri/arcgis/OAuthInfo",&lt;BR /&gt;"esri/IdentityManager",&lt;BR /&gt;"dojo/dom-style"&lt;BR /&gt;],&lt;BR /&gt;function (&lt;BR /&gt;dom,&lt;BR /&gt;parser,&lt;BR /&gt;Portal,&lt;BR /&gt;OAuthInfo,&lt;BR /&gt;esriId,&lt;BR /&gt;domStyle) {&lt;BR /&gt;parser.parse();&lt;/P&gt;&lt;P&gt;arcgisLogin();&lt;/P&gt;&lt;P&gt;function arcgisLogin() {&lt;BR /&gt;var info = new OAuthInfo({&lt;BR /&gt;appId: "[Id from the app I created]",&lt;BR /&gt;portalUrl: "[URL to organization portal]",&lt;BR /&gt;popup: false&lt;BR /&gt;});&lt;BR /&gt;esriId.registerOAuthInfos([info]);&lt;/P&gt;&lt;P&gt;esriId&lt;BR /&gt;.checkSignInStatus(info.portalUrl + "/sharing/rest")&lt;BR /&gt;.then(function () {&lt;BR /&gt;handleSignedIn();&lt;BR /&gt;})&lt;BR /&gt;.otherwise(function () {&lt;BR /&gt;domStyle.set("anonymousPanel", "display", "block");&lt;BR /&gt;domStyle.set("personalizedPanel", "display", "none");&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;document.getElementById("sign-in").addEventListener("click", function () {&lt;BR /&gt;esriId.getCredential(info.portalUrl + "/sharing/rest");&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;document.getElementById("sign-out").addEventListener("click", function () {&lt;BR /&gt;esriId.destroyCredentials();&lt;BR /&gt;window.location.reload();&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;function handleSignedIn() {&lt;/P&gt;&lt;P&gt;var portal = new Portal();&lt;/P&gt;&lt;P&gt;portal.load().then(function () {&lt;BR /&gt;const results = { name: portal.user.fullName, username: portal.user.username };&lt;BR /&gt;otherMapFeatures();&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2023 17:07:09 GMT</pubDate>
    <dc:creator>tad</dc:creator>
    <dc:date>2023-06-02T17:07:09Z</dc:date>
    <item>
      <title>Oauth 2.0 Sign in</title>
      <link>https://community.esri.com/t5/developers-questions/oauth-2-0-sign-in/m-p/1295139#M6625</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have an old web map, created in C#, that utilizes the ArcGIS API for JavaScript 3. Currently, there is a proxy used to log into the organizational account to utilize the web map. I am attempting to update the code to use Oauth to sign into the ArcGIS Enterprise account instead.&lt;/P&gt;&lt;P&gt;Things work until it checks if the user is signed in, which is false. I'm currently getting an error with the domStyle panels (Cannot read properties of null (reading 'style')).&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks, tad&lt;/P&gt;&lt;P&gt;Here is the code (apologies for non-formatted):&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;"dojo/dom",&lt;BR /&gt;"dojo/parser",&lt;BR /&gt;"esri/arcgis/Portal",&lt;BR /&gt;"esri/arcgis/OAuthInfo",&lt;BR /&gt;"esri/IdentityManager",&lt;BR /&gt;"dojo/dom-style"&lt;BR /&gt;],&lt;BR /&gt;function (&lt;BR /&gt;dom,&lt;BR /&gt;parser,&lt;BR /&gt;Portal,&lt;BR /&gt;OAuthInfo,&lt;BR /&gt;esriId,&lt;BR /&gt;domStyle) {&lt;BR /&gt;parser.parse();&lt;/P&gt;&lt;P&gt;arcgisLogin();&lt;/P&gt;&lt;P&gt;function arcgisLogin() {&lt;BR /&gt;var info = new OAuthInfo({&lt;BR /&gt;appId: "[Id from the app I created]",&lt;BR /&gt;portalUrl: "[URL to organization portal]",&lt;BR /&gt;popup: false&lt;BR /&gt;});&lt;BR /&gt;esriId.registerOAuthInfos([info]);&lt;/P&gt;&lt;P&gt;esriId&lt;BR /&gt;.checkSignInStatus(info.portalUrl + "/sharing/rest")&lt;BR /&gt;.then(function () {&lt;BR /&gt;handleSignedIn();&lt;BR /&gt;})&lt;BR /&gt;.otherwise(function () {&lt;BR /&gt;domStyle.set("anonymousPanel", "display", "block");&lt;BR /&gt;domStyle.set("personalizedPanel", "display", "none");&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;document.getElementById("sign-in").addEventListener("click", function () {&lt;BR /&gt;esriId.getCredential(info.portalUrl + "/sharing/rest");&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;document.getElementById("sign-out").addEventListener("click", function () {&lt;BR /&gt;esriId.destroyCredentials();&lt;BR /&gt;window.location.reload();&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;function handleSignedIn() {&lt;/P&gt;&lt;P&gt;var portal = new Portal();&lt;/P&gt;&lt;P&gt;portal.load().then(function () {&lt;BR /&gt;const results = { name: portal.user.fullName, username: portal.user.username };&lt;BR /&gt;otherMapFeatures();&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 17:07:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/oauth-2-0-sign-in/m-p/1295139#M6625</guid>
      <dc:creator>tad</dc:creator>
      <dc:date>2023-06-02T17:07:09Z</dc:date>
    </item>
  </channel>
</rss>

