-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharcgis_client.js
37 lines (32 loc) · 1.25 KB
/
arcgis_client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Arcgis.requestCredential = function(options, credentialRequestCompleteCallback) {
// support both (options, callback) and (callback).
if (!credentialRequestCompleteCallback && typeof options === 'function') {
credentialRequestCompleteCallback = options;
options = {};
} else if (!options) {
options = {};
}
var config = ServiceConfiguration.configurations.findOne({
service: 'arcgis'
});
if (!config) {
credentialRequestCompleteCallback && credentialRequestCompleteCallback(new ServiceConfiguration.ConfigError());
return;
}
// Force the user to approve the app every time (similar to Google's `approval_prompt`).
var showDialog = options.showDialog || true;
var credentialToken = Random.secret();
var loginStyle = OAuth._loginStyle('arcgis', config, options);
var loginURL = 'https://www.arcgis.com/sharing/oauth2/authorize'+
'?response_type=code'+
'&client_id='+config.clientId+
'&redirect_uri='+OAuth._redirectUri('arcgis', config)+
'&state='+ OAuth._stateParam(loginStyle, credentialToken);
OAuth.launchLogin({
loginService: 'arcgis',
loginStyle: loginStyle,
loginUrl: loginURL,
credentialRequestCompleteCallback: credentialRequestCompleteCallback,
credentialToken: credentialToken
});
};