Oauth with Esri React

1426
1
03-10-2021 01:17 PM
cyk
by
New Contributor

I need to use oauth2 to allow users on our platform to login with Esri and view their private layers. With vanilla javascript, I would use IdentityManager  however, I cannot find an equivalent for use in React. Namely, I don't know what import statement to use to import the identity manager and oauth Esri packages.

 

I've found the arcgis node repo but the documentation doesn't state how I can use oauth.

0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

This app uses Vue with OAuth, but the patterns are the same regardless of framework being used.

https://github.com/odoe/map-vue/blob/master/src/data/auth.ts

 

You can replace with the imports from esri to @ arcgis/core if you use the ESM package.

Don't forget to have an oauth-callback.html page as shown here.

https://github.com/Esri/jsapi-resources/blob/8f21b5a66256e855f2899764239cf2b3fb990c7e/oauth/oauth-ca...

 

The syntax on the page is different than what is in the vue app above.

0 Kudos