<?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 Share OAuth Access Token server-side &amp; client-side? in ArcGIS Enterprise Portal Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/share-oauth-access-token-server-side-client-side/m-p/580165#M7916</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;We're authenticating against ArcGIS Portal from an&amp;nbsp;ASP.NET MVC web application using &lt;A href="https://github.com/TerribleDev/OwinOAuthProviders/tree/master/src/Owin.Security.Providers.ArcGISPortal"&gt;Owin.Security.Providers.ArcGISPortal&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;For the page that shows the webmap we'd like to re-use the server-side obtained access token, rather than requiring&amp;nbsp;the user to login a 2nd time with&amp;nbsp;the same credentials using the ArcGIS API for JavaScript 3.22.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;Is there anyway to achieve this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following the linked example found through the documentation for &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/identitymanagerbase-amd.html#registertoken"&gt;esri.IdentityManager.registerToken()&lt;/A&gt;, I've tried the following method to share the access token:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var credentialsJSON = {&lt;BR /&gt; serverInfos: [{&lt;BR /&gt;&lt;SPAN&gt; server: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D" rel="nofollow" target="_blank"&gt;https://[HOST]&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; tokenServiceUrl: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis%2Ftokens%2F" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis/tokens/&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; adminTokenServiceUrl: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis%2Fadmin%2FgenerateToken" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis/admin/generateToken&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt; shortLivedTokenValidity: 1800,&lt;BR /&gt; currentVersion: 10.5,&lt;BR /&gt; hasServer: true&lt;BR /&gt; }],&lt;BR /&gt; oAuthInfos: [],&lt;BR /&gt; credentials: [{&lt;BR /&gt; userId: user.userId,&lt;BR /&gt;&lt;SPAN&gt; server: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt; token: user.userAccessToken,&lt;BR /&gt; expires: user.userAccessTokenExpiry,&lt;BR /&gt; validity: 1800,&lt;BR /&gt; isAdmin: false,&lt;BR /&gt; ssl: false,&lt;BR /&gt; creationTime: user.userAccessTokenIssued,&lt;BR /&gt; scope: "server"&lt;BR /&gt; }]&lt;BR /&gt; };&lt;BR /&gt; esriId.initialize(credentialsJSON);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I'm still not getting access to the webmap. I see a html login modal over the empty map div with the title "Please sign in to access the item on &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis&lt;/A&gt;&lt;SPAN&gt; (b11824af61df463586dad40d1df7abbd)".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the console log I see the following message logged:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;dojo.io.script error Error: You do not have permissions to access this resource or perform this operation.&lt;BR /&gt; at Object.g.load (init.js:984)&lt;BR /&gt; at init.js:87&lt;BR /&gt; at c (init.js:103)&lt;BR /&gt; at d (init.js:103)&lt;BR /&gt; at a.Deferred.resolve.callback (init.js:105)&lt;BR /&gt; at c (init.js:104)&lt;BR /&gt; at d (init.js:103)&lt;BR /&gt; at a.Deferred.resolve.callback (init.js:105)&lt;BR /&gt; at init.js:999&lt;BR /&gt; at n (init.js:107)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;and for the network request to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis%2Fsharing%2Frest%2Fcontent%2Fitems%2Fb11824af61df463586dad40d1df7abbd%3Ff%3Djson%26callback%3Ddojo.io.script.jsonp_dojoIoScript1._jsonpCallback" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis/sharing/rest/content/items/b11824af61df463586dad40d1df7abbd?f=json&amp;amp;callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see the following response:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}});&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Dec 2017 23:07:00 GMT</pubDate>
    <dc:creator>GavinHarriss</dc:creator>
    <dc:date>2017-12-12T23:07:00Z</dc:date>
    <item>
      <title>Share OAuth Access Token server-side &amp; client-side?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/share-oauth-access-token-server-side-client-side/m-p/580165#M7916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;We're authenticating against ArcGIS Portal from an&amp;nbsp;ASP.NET MVC web application using &lt;A href="https://github.com/TerribleDev/OwinOAuthProviders/tree/master/src/Owin.Security.Providers.ArcGISPortal"&gt;Owin.Security.Providers.ArcGISPortal&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;For the page that shows the webmap we'd like to re-use the server-side obtained access token, rather than requiring&amp;nbsp;the user to login a 2nd time with&amp;nbsp;the same credentials using the ArcGIS API for JavaScript 3.22.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: #ffffff;"&gt;Is there anyway to achieve this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following the linked example found through the documentation for &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/identitymanagerbase-amd.html#registertoken"&gt;esri.IdentityManager.registerToken()&lt;/A&gt;, I've tried the following method to share the access token:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var credentialsJSON = {&lt;BR /&gt; serverInfos: [{&lt;BR /&gt;&lt;SPAN&gt; server: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D" rel="nofollow" target="_blank"&gt;https://[HOST]&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; tokenServiceUrl: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis%2Ftokens%2F" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis/tokens/&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; adminTokenServiceUrl: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis%2Fadmin%2FgenerateToken" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis/admin/generateToken&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt; shortLivedTokenValidity: 1800,&lt;BR /&gt; currentVersion: 10.5,&lt;BR /&gt; hasServer: true&lt;BR /&gt; }],&lt;BR /&gt; oAuthInfos: [],&lt;BR /&gt; credentials: [{&lt;BR /&gt; userId: user.userId,&lt;BR /&gt;&lt;SPAN&gt; server: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis&lt;/A&gt;&lt;SPAN&gt;",&lt;/SPAN&gt;&lt;BR /&gt; token: user.userAccessToken,&lt;BR /&gt; expires: user.userAccessTokenExpiry,&lt;BR /&gt; validity: 1800,&lt;BR /&gt; isAdmin: false,&lt;BR /&gt; ssl: false,&lt;BR /&gt; creationTime: user.userAccessTokenIssued,&lt;BR /&gt; scope: "server"&lt;BR /&gt; }]&lt;BR /&gt; };&lt;BR /&gt; esriId.initialize(credentialsJSON);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I'm still not getting access to the webmap. I see a html login modal over the empty map div with the title "Please sign in to access the item on &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis&lt;/A&gt;&lt;SPAN&gt; (b11824af61df463586dad40d1df7abbd)".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the console log I see the following message logged:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;dojo.io.script error Error: You do not have permissions to access this resource or perform this operation.&lt;BR /&gt; at Object.g.load (init.js:984)&lt;BR /&gt; at init.js:87&lt;BR /&gt; at c (init.js:103)&lt;BR /&gt; at d (init.js:103)&lt;BR /&gt; at a.Deferred.resolve.callback (init.js:105)&lt;BR /&gt; at c (init.js:104)&lt;BR /&gt; at d (init.js:103)&lt;BR /&gt; at a.Deferred.resolve.callback (init.js:105)&lt;BR /&gt; at init.js:999&lt;BR /&gt; at n (init.js:107)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;and for the network request to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F%5BHOST%5D%2Farcgis%2Fsharing%2Frest%2Fcontent%2Fitems%2Fb11824af61df463586dad40d1df7abbd%3Ff%3Djson%26callback%3Ddojo.io.script.jsonp_dojoIoScript1._jsonpCallback" rel="nofollow" target="_blank"&gt;https://[HOST]/arcgis/sharing/rest/content/items/b11824af61df463586dad40d1df7abbd?f=json&amp;amp;callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see the following response:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}});&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2017 23:07:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/share-oauth-access-token-server-side-client-side/m-p/580165#M7916</guid>
      <dc:creator>GavinHarriss</dc:creator>
      <dc:date>2017-12-12T23:07:00Z</dc:date>
    </item>
  </channel>
</rss>

