ArcGIS Online App login: OAuth, Token, IdentityManager. Steps inside. Help!

04-26-2019 07:25 AM
New Contributor

Dear ArcGIS Developers,

I have a public website where I display a ArcGIS Online map, the 'satellite' basemap with 'world-elevation'.

I do not want my website users to be prompted with any ESRI login form; instead, I just want to pay ESRI for the amount of map tiles that my users consume.

The map is working fine, but I can see that the "usage" in my ESRI App Dashboard is stuck to 0; I believe this is because the 'token' I'm generating is not being attached to each tiles request, as it should be.

Here are my steps:
1. I follow this guide
- I create a new 'App' in my ESRI Developer Dashboard, I set it as public, and I note down client_secret and client_id.
- In the website backend I call the service to generate a OAuth Token, feeding it with my client_id and client_secret, and I get back an object with Token and Expiration.

- Then I send Token and Expiration to my JS front-end.

2. Now in JS, first I register the token:

  server: '',
  token: <esri_token from the backend>


I also do:
var oAuthInfo = new OAuthInfo({
  appId: <my App client_id>,
  popup: false


And I check that it's working:
esriId.checkSignInStatus('').then(function(responseSignInStatus) {
  console.log('Sign In Status OK');
  console.log("Error message: ", error);

All of the above is based on the documentation and samples:

Now on the issue:

I open the Developer Tools, tab "Network" and I can see that the Token is not being attached to the map tiles requests. The documentation says that once the token is registered, and my App is signed in, then the token will be attached to all the Ajax calls. This does not seem to happen unfortunately.

Can anyone please help me with this?

- Older threads in this forum suggest to reconstruct the Object originally given to esriId.registerToken (Credentials + Oauth + ServerInfo) and do esriId.initialize(); I did try that without much luck, furthermore it looks to me a bit non-sense. Isn't IdentityManager supposed to manage the access already?
- Yes I did try to setup a Proxy, and it works; but it's also very slow and it does not fit my use-case, it takes too long to load new tiles when zooming/panning.

Any help is much appreciated. Thanks!


0 Kudos
0 Replies