<?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 IdentityManager's getCredential is not returning a deferred object. in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/identitymanager-s-getcredential-is-not-returning-a/m-p/524097#M3570</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an application with oAuth 2.0 authentication with the pop up. I followed the exact same tutorial from this website&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_popup.html" title="https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_popup.html"&gt;OAuth Popup | ArcGIS API for JavaScript 3.19&lt;/A&gt;&amp;nbsp;. Below is the current code I have for my application. I am able to sign in and get the token back and the pop up closes successfully. Since getCredential returns a deferred object i have a .then(function() {}) to take care of changing the display to show the user name. My application never hits the break point in the function for .then() or .otherwise() after the getCredential function call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something here that needs to be&amp;nbsp;in the required statement? I am not getting any error messages upon debug. It looks like it signed in right but it just never catches on the promise to save the Credential object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is very much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;require([&lt;BR /&gt; "esri/arcgis/Portal", &lt;BR /&gt; "esri/arcgis/OAuthInfo", &lt;BR /&gt; "esri/IdentityManager",&lt;BR /&gt; "esri/ServerInfo",&lt;BR /&gt; &lt;BR /&gt; "dijit/registry",&lt;/P&gt;&lt;P&gt;"dojo/query",&lt;BR /&gt; "dojo/dom-style", &lt;BR /&gt; "dojo/dom-attr", &lt;BR /&gt; "dojo/dom", &lt;BR /&gt; "dojo/on", &lt;BR /&gt; "dojo/_base/array",&lt;BR /&gt; "dojo/domReady!"&lt;BR /&gt; ],&lt;/P&gt;&lt;P&gt;function (&lt;BR /&gt; arcgisPortal, &lt;BR /&gt; OAuthInfo, &lt;BR /&gt; esriId,&lt;BR /&gt; ServerInfo,&lt;/P&gt;&lt;P&gt;registry, &lt;BR /&gt; query,&lt;BR /&gt; domStyle, &lt;BR /&gt; domAttr, &lt;BR /&gt; dom, &lt;BR /&gt; on, &lt;BR /&gt; arrayUtils) {&lt;/P&gt;&lt;P&gt;var info = new OAuthInfo({&lt;BR /&gt; appId: "YourAppID",&lt;BR /&gt; portalUrl: "YourPortalUrl",&lt;BR /&gt; popup: true&lt;BR /&gt; });&lt;BR /&gt; esriId.registerOAuthInfos([info]);&lt;/P&gt;&lt;P&gt;on(dom.byId("sign-in"), "click", function (){&lt;BR /&gt; // user will be shown the OAuth Sign In page&lt;BR /&gt; esriId.getCredential(info.portalUrl + "/sharing", {&lt;BR /&gt; oAuthPopupConfirmation: false&lt;BR /&gt; }&lt;BR /&gt; ).then(function (){&lt;BR /&gt; var currentToken = esriId.checkSignInStatus();&lt;BR /&gt; console.log(currentToken);&lt;BR /&gt; displayItems();&lt;BR /&gt; }).otherwise(&lt;BR /&gt; function (error){&lt;BR /&gt; console.log("Error occurred while signing in: ", error);&lt;BR /&gt; }&lt;BR /&gt; );&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;on(dom.byId("sign-out"), "click", function (){&lt;BR /&gt; esriId.destroyCredentials();&lt;BR /&gt; window.location.reload();&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt;window.oauthCallback = function(token) {&lt;BR /&gt; accesstoken = token;&lt;BR /&gt; console.log("Token is: " + accesstoken);&lt;BR /&gt; &lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;function displayItems(){&lt;BR /&gt; new arcgisPortal.Portal("portalUrl").signIn().then(&lt;BR /&gt; function (portalUser){&lt;BR /&gt; console.log("Signed in to the portal: ", portalUser);&lt;/P&gt;&lt;P&gt;domAttr.set("userId", "innerHTML", portalUser.fullName);&lt;BR /&gt; domStyle.set("anonymousPanel", "display", "none");&lt;BR /&gt; domStyle.set("Navigation", "display", "block");&lt;BR /&gt; domStyle.set("personalizedPanel", "display", "block");&lt;/P&gt;&lt;P&gt;queryPortal(portalUser);&lt;BR /&gt; }&lt;BR /&gt; ).otherwise(&lt;BR /&gt; function (error){&lt;BR /&gt; console.log("Error occurred while signing in: ", error);&lt;BR /&gt; }&lt;BR /&gt; );&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;function queryPortal(portalUser){&lt;BR /&gt; var portal = portalUser.portal;&lt;/P&gt;&lt;P&gt;var queryParams = {&lt;BR /&gt; q: "owner:" + portalUser.username,&lt;BR /&gt; sortField: "numViews",&lt;BR /&gt; sortOrder: "desc",&lt;BR /&gt; num: 20&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;portal.queryItems(queryParams).then(createGallery);&lt;BR /&gt; }&lt;BR /&gt; function createGallery(items){&lt;BR /&gt; var htmlFragment = "";&lt;/P&gt;&lt;P&gt;arrayUtils.forEach(items.results, function (item){&lt;BR /&gt; htmlFragment += (&lt;BR /&gt; "&amp;lt;div class=\"esri-item-container\"&amp;gt;" +&lt;BR /&gt; (&lt;BR /&gt; item.thumbnailUrl ?&lt;BR /&gt; "&amp;lt;div class=\"esri-image\" style=\"background-image:url(" + item.thumbnailUrl + ");\"&amp;gt;&amp;lt;/div&amp;gt;" :&lt;BR /&gt; "&amp;lt;div class=\"esri-image esri-null-image\"&amp;gt;Thumbnail not available&amp;lt;/div&amp;gt;"&lt;BR /&gt; ) +&lt;BR /&gt; (&lt;BR /&gt; item.title ?&lt;BR /&gt; "&amp;lt;div class=\"esri-title\"&amp;gt;" + (item.title || "") + "&amp;lt;/div&amp;gt;" :&lt;BR /&gt; "&amp;lt;div class=\"esri-title esri-null-title\"&amp;gt;Title not available&amp;lt;/div&amp;gt;"&lt;BR /&gt; ) +&lt;BR /&gt; "&amp;lt;/div&amp;gt;"&lt;BR /&gt; );&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;dom.byId("itemGallery").innerHTML = htmlFragment;&lt;BR /&gt; };&lt;BR /&gt;});&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Jan 2017 16:24:49 GMT</pubDate>
    <dc:creator>PalakBhojani</dc:creator>
    <dc:date>2017-01-09T16:24:49Z</dc:date>
    <item>
      <title>IdentityManager's getCredential is not returning a deferred object.</title>
      <link>https://community.esri.com/t5/developers-questions/identitymanager-s-getcredential-is-not-returning-a/m-p/524097#M3570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an application with oAuth 2.0 authentication with the pop up. I followed the exact same tutorial from this website&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_popup.html" title="https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_popup.html"&gt;OAuth Popup | ArcGIS API for JavaScript 3.19&lt;/A&gt;&amp;nbsp;. Below is the current code I have for my application. I am able to sign in and get the token back and the pop up closes successfully. Since getCredential returns a deferred object i have a .then(function() {}) to take care of changing the display to show the user name. My application never hits the break point in the function for .then() or .otherwise() after the getCredential function call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something here that needs to be&amp;nbsp;in the required statement? I am not getting any error messages upon debug. It looks like it signed in right but it just never catches on the promise to save the Credential object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is very much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;require([&lt;BR /&gt; "esri/arcgis/Portal", &lt;BR /&gt; "esri/arcgis/OAuthInfo", &lt;BR /&gt; "esri/IdentityManager",&lt;BR /&gt; "esri/ServerInfo",&lt;BR /&gt; &lt;BR /&gt; "dijit/registry",&lt;/P&gt;&lt;P&gt;"dojo/query",&lt;BR /&gt; "dojo/dom-style", &lt;BR /&gt; "dojo/dom-attr", &lt;BR /&gt; "dojo/dom", &lt;BR /&gt; "dojo/on", &lt;BR /&gt; "dojo/_base/array",&lt;BR /&gt; "dojo/domReady!"&lt;BR /&gt; ],&lt;/P&gt;&lt;P&gt;function (&lt;BR /&gt; arcgisPortal, &lt;BR /&gt; OAuthInfo, &lt;BR /&gt; esriId,&lt;BR /&gt; ServerInfo,&lt;/P&gt;&lt;P&gt;registry, &lt;BR /&gt; query,&lt;BR /&gt; domStyle, &lt;BR /&gt; domAttr, &lt;BR /&gt; dom, &lt;BR /&gt; on, &lt;BR /&gt; arrayUtils) {&lt;/P&gt;&lt;P&gt;var info = new OAuthInfo({&lt;BR /&gt; appId: "YourAppID",&lt;BR /&gt; portalUrl: "YourPortalUrl",&lt;BR /&gt; popup: true&lt;BR /&gt; });&lt;BR /&gt; esriId.registerOAuthInfos([info]);&lt;/P&gt;&lt;P&gt;on(dom.byId("sign-in"), "click", function (){&lt;BR /&gt; // user will be shown the OAuth Sign In page&lt;BR /&gt; esriId.getCredential(info.portalUrl + "/sharing", {&lt;BR /&gt; oAuthPopupConfirmation: false&lt;BR /&gt; }&lt;BR /&gt; ).then(function (){&lt;BR /&gt; var currentToken = esriId.checkSignInStatus();&lt;BR /&gt; console.log(currentToken);&lt;BR /&gt; displayItems();&lt;BR /&gt; }).otherwise(&lt;BR /&gt; function (error){&lt;BR /&gt; console.log("Error occurred while signing in: ", error);&lt;BR /&gt; }&lt;BR /&gt; );&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;on(dom.byId("sign-out"), "click", function (){&lt;BR /&gt; esriId.destroyCredentials();&lt;BR /&gt; window.location.reload();&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt;window.oauthCallback = function(token) {&lt;BR /&gt; accesstoken = token;&lt;BR /&gt; console.log("Token is: " + accesstoken);&lt;BR /&gt; &lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;function displayItems(){&lt;BR /&gt; new arcgisPortal.Portal("portalUrl").signIn().then(&lt;BR /&gt; function (portalUser){&lt;BR /&gt; console.log("Signed in to the portal: ", portalUser);&lt;/P&gt;&lt;P&gt;domAttr.set("userId", "innerHTML", portalUser.fullName);&lt;BR /&gt; domStyle.set("anonymousPanel", "display", "none");&lt;BR /&gt; domStyle.set("Navigation", "display", "block");&lt;BR /&gt; domStyle.set("personalizedPanel", "display", "block");&lt;/P&gt;&lt;P&gt;queryPortal(portalUser);&lt;BR /&gt; }&lt;BR /&gt; ).otherwise(&lt;BR /&gt; function (error){&lt;BR /&gt; console.log("Error occurred while signing in: ", error);&lt;BR /&gt; }&lt;BR /&gt; );&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;function queryPortal(portalUser){&lt;BR /&gt; var portal = portalUser.portal;&lt;/P&gt;&lt;P&gt;var queryParams = {&lt;BR /&gt; q: "owner:" + portalUser.username,&lt;BR /&gt; sortField: "numViews",&lt;BR /&gt; sortOrder: "desc",&lt;BR /&gt; num: 20&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;portal.queryItems(queryParams).then(createGallery);&lt;BR /&gt; }&lt;BR /&gt; function createGallery(items){&lt;BR /&gt; var htmlFragment = "";&lt;/P&gt;&lt;P&gt;arrayUtils.forEach(items.results, function (item){&lt;BR /&gt; htmlFragment += (&lt;BR /&gt; "&amp;lt;div class=\"esri-item-container\"&amp;gt;" +&lt;BR /&gt; (&lt;BR /&gt; item.thumbnailUrl ?&lt;BR /&gt; "&amp;lt;div class=\"esri-image\" style=\"background-image:url(" + item.thumbnailUrl + ");\"&amp;gt;&amp;lt;/div&amp;gt;" :&lt;BR /&gt; "&amp;lt;div class=\"esri-image esri-null-image\"&amp;gt;Thumbnail not available&amp;lt;/div&amp;gt;"&lt;BR /&gt; ) +&lt;BR /&gt; (&lt;BR /&gt; item.title ?&lt;BR /&gt; "&amp;lt;div class=\"esri-title\"&amp;gt;" + (item.title || "") + "&amp;lt;/div&amp;gt;" :&lt;BR /&gt; "&amp;lt;div class=\"esri-title esri-null-title\"&amp;gt;Title not available&amp;lt;/div&amp;gt;"&lt;BR /&gt; ) +&lt;BR /&gt; "&amp;lt;/div&amp;gt;"&lt;BR /&gt; );&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;dom.byId("itemGallery").innerHTML = htmlFragment;&lt;BR /&gt; };&lt;BR /&gt;});&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 16:24:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/identitymanager-s-getcredential-is-not-returning-a/m-p/524097#M3570</guid>
      <dc:creator>PalakBhojani</dc:creator>
      <dc:date>2017-01-09T16:24:49Z</dc:date>
    </item>
  </channel>
</rss>

