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.
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.
The syntax on the page is different than what is in the vue app above.