1. URL to get user_code
REST API documentation: oauth2/authorize
Check the arcgis-oauth-pkce repo to if you need help generating the code_verifier
and code_challenge
.
let crypto;
try {
crypto = require("crypto");
} catch (err) {
console.log('Run $npm install first!');
}
function base64URLEncode(str) {
return str.toString('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
}
const verifier = base64URLEncode(crypto.randomBytes(32));
console.log("Code verifier: ", verifier);
function sha256(buffer) {
return crypto.createHash('sha256').update(buffer).digest();
}
const challenge = base64URLEncode(sha256(verifier));
console.log("Code challenge: ", challenge);
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
client_id | string | (Required) The ID of the registered application. Use: https://developers.arcgis.com/applications/ | |
redirect_uri | string | (Required) {{client_id}}'s "Redirect URLs" have to be configured to accept it. For web: https://.... | |
response_type | string | (Required) Type of grant, either implicit (token) or authorization (code) | |
code_challenge | string | (Required) Check doc in the sidebar | |
code_challenge_method | string | (Required) Indicates whether the code_challenge value is SHA256 hash or plain text | |
expiration | number | For refresh_token (specified in minutes). Max. 129600 minutes (90 days) | |
state | string | Value used by applications to maintain state between authorization requests and responses or pass along additional app-specific information. This also allows you to prevent CSRF attacks by confirming that the value coming from the response matches the one you sent. | |
locale | string | The login page will be rendered using the language corresponding to that locale | |
style | string | Color scheme used to render the login page regardless of browser or operating system settings (light |
RESPONSES
status: OK
"\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n \u003chead\u003e\n \u003cmeta charset=\"UTF-8\"\u003e\n \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"\u003e\n \u003cmeta name=\"referrer\" content=\"origin\"\u003e\n \u003ctitle\u003eSign In\u003c/title\u003e\n \u003cscript src=\"/sharing/files/scripts/detector.min.js?v=1A68A60\"\u003e\u003c/script\u003e\n \u003clink rel=\"stylesheet\" href=\"/sharing/files/css/site.min.css?v=1A68A60\"\u003e\n \u003cscript src=\"/sharing/files/scripts/theme.min.js?v=1A68A60\"\u003e\u003c/script\u003e\n \u003cscript\u003e\n var oAuthInfo = {\"oauth_state\":\"aZ_wdQevDlQgzczttk-2ofw..mIFOarea-hLrVutifd70h96wi1SkD7o_0limxpv6CffTD5h-6hF07Abi7zTRR3MCOhHEgRpIFaXmKVfEbVYaNyxAQwCKqo4z9Ild15M-yAHL8mK_GcB77LnrU9Y45Cnq9lsvjXz9XF-pz7uXKOyw26bg2yGtQ5oTgnfnP9RbFuUscnF0C0E1lPcSMYO0hHUdZmETxzLgebCuneAHSsEellcsfX8FCMwIQFHdAMcj7JQ6XasZwxWHwLh99_GIttWc_Y6lIb6Q3qOxQA8DlPXNW7B7YPduGHZ00BzB-dMTYESGeEy_09PQt2rXJmzm3AHcMc93uVocT-2jKSwoJ6ja_xtRuX4ckm7on0YZ-sOlO66BqiwfKu3eidO2EEC6PqlIYlk_HaSN9b5R8GC3ILptxkILmq6SqoptNbgTEIWqRQi_0ldwIAx5-ZEiVYxXPg..\",\"client_id\":\"13UCJocz87fHJNs6\",\"appTitle\":\"oAuth app DevSummit Berlin 2022\",\"locale\":\"en\",\"persistOption\":true,\"showSocialLogins\":true,\"contextPath\":\"/sharing\",\"appOrgInfo\":{\"id\":\"Q6ZFRRvMTlsTTFuP\",\"name\":\"Raul Jimenez Ortega Account\",\"description\":\"This is the organisation page of my developer account. You can see here some of the projects I have participated. If you want to read more about me please go to rauljimenez.info\",\"thumbnail\":\"thumbnail.png\"},\"orgUrlBase\":\"maps.arcgis.com\",\"helpBase\":\"https://doc.arcgis.com/en/arcgis-online/\",\"socialProviders\":[\"github\",\"facebook\",\"google\",\"apple\"],\"originSignin\":false}\n window.setTheme(oAuthInfo, \"/sharing\");\n \u003c/script\u003e\n \u003cscript src=\"/sharing/files/scripts/oauth2.js?v=1A68A60\"\u003e\u003c/script\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv class=\"content-container\"\u003e\u003c/div\u003e\n \u003c/body\u003e\n \u003cscript\u003e\n oAuthInfo.locale = ((oAuthInfo.locale \u0026\u0026 oAuthInfo.locale === \"iw\") ? \"he\" : oAuthInfo.locale);\n require.config({\n baseUrl: \"/sharing/files/scripts/\",\n locale: oAuthInfo.locale \u0026\u0026 oAuthInfo.locale.toLowerCase() || \"\"\n });\n require([\"signIn\", \"domReady!\"], function (signIn) {\n signIn.startup(oAuthInfo);\n });\n\u003c/script\u003e\n\u003c/html\u003e"