There are situations when it is not possible to use a secure OAuth 2.0 flow to obtain an access tokengenerate operation allows you to get an access token using your username and password. This flow adheres to the resource owner password credentials grant type defined in the OAuth 2.0 specification.
Get an access token
To get an access token, use the generate operation and set a username, password, and referer. The generate operation only supports POST requests.
curl https://www.arcgis.com/sharing/rest/generateToken \
-d 'f=json' \
-d 'username=USERNAME' \
-d 'password=PASSWORD' \
-d 'referer=https://www.arcgis.com' \
-d 'client=referer'