Select to view content in your preferred language

How to apply token when using client_credentials / apiKey to access an ArcGis Enterprise Map

115
0
Tuesday
RockyCherry
New Contributor

Hello, 

I'm trying to access a map on our new ArcGis Enterprise instance. Our admin has created a client_id and client_secret and I've used those to successfully retrieve a token using the following url: 

string arcGisTokenUrl = $"{_arcGisOptions.ServerUrl}/portal/sharing/rest/oauth2/token";

I'm then using that token in our React application like this:  

      const portalUrl = 'https://our.arcgis.enterprise.domain.com/portal';
      const serverUrl = 'https://our.arcgis.enterprise.domain.com/server';

      esriConfig.portalUrl = portalUrl

      esriConfig.apiKeys.scopes = [{
        token: tokenToUse?.token || '',
        urls: [portalUrl, serverUrl]
      }]     

My issue is the map I'm loading has an arcgis online base layer. It apperas that setting the portalUrl ito my server is causing the base layer map features to fail with an "Invalid Token" error.  I'm not sure how to fix this, as I have to set the portalUrl, but I can't set it if I want to use public basemaps?  

What can I do? 

0 Kudos
0 Replies