Hello,
Could anyone tell me what should be the best way to generate token in ArcGIS for JavaScript. If I hard-code the credential information, it would be risky because other people could get my clientId and clientSecret easily. One possible way could be using the proxy, but as I add the serverUrl with app id and secret, I would still get a response that says client_id is not specified. So I am wondering if I didn't get this right or if there is a better solution.
The config settting is like:
<serverUrl url="https://www.arcgis.com/sharing/rest/oauth2/token"
clientId="<appid>"
clientSecret="<secret>"
matchAll="true"/>
And the local request url is like:
localhost/proxy/DotNet/proxy.ashx?https://www.arcgis.com/sharing/rest/oauth2/token?grant_type=client_credentials&expiration=20160
ps: If I put the clientId and secret within the url, it works all good.
Thanks!
Maybe IdentityManager's generateToken()?
IdentityManager | API Reference | ArcGIS API for JavaScript 4.0