Good Day
I'm trying to verify my application settings without having to direct through the login system.
I have a page with the following formation on it (this is an Angular Application):
Server URL
App ID
App Secret
Server Type: Online vs Enterprise
Token URL
What I want, is to pass the data into the Identity Manager and have it give me back a successful response, to verify the data is correct. Every time I call the Identity Manager, with this flow:
const info = new OAuthInfo({
appId: portalConfig.appId,
flowType: 'auto',
popup: popup
});
IdentityManager.registerOAuthInfos([info]);
IdentityManager.getCredential(portalConfig.serverURL + '/sharing').then(() => {
IdentityManager.checkSignInStatus(portalConfig.serverURL + "/sharing").then(() => {
r(portalConfig.serverURL);
}).catch((error) => {
console.log('Error - Identity Manager - Check Sign In Status');
console.log(error);
j(error);
})
}).catch((error) => {
console.log('Error - Identity Manager - Get Credential');
console.log(error);
j(error);
})
I get redirected to a window that asks if I want to allow that connection
How can I bypass this Windows? I'm using ArcGIS Code 4.29.7.
Thanks
I found a workaround, if you ever run into this, but it requires a username / password.
const param = {
username: this.username,
password: this.password
}
// @ts-ignore
esriId.generateToken(serverInfo, param).then((tokenRes: any) => {
esriId.registerToken({server: serverURL, token: tokenRes.token});
esriId.checkAppAccess(serverURL, appId).then((getCredRes) => {
r(getCredRes);
}).catch((error) => {
console.log('Error - Checking App Access');
console.log(error);
j(error);
})
r(serverURL);
}).catch((error) => {
console.log('Error - Generating Token');
console.log(error);
j(error);
})
Then you'll be able to use the connection without getting stopped :).
An instance of ArcGISIdentityManager can be created with several different methods including helper methods for OAuth 2.0 user authentication workflows.
import { ArcGISIdentityManager } from "@esri/arcgis-rest-request"; ArcGISIdentityManager.beginOAuth2({ clientId: "YOUR_CLIENT_ID", redirectUri: "YOUR_REDIRECT_URI" }).then((manager) => { console.log(manager); });
Refer this link for more details -
https://developers.arcgis.com/arcgis-rest-js/authentication/
It is not recommended to construct ArcGISIdentityManager directly. Instead there are several static methods used for specific workflows. The 2 primary workflows relate to oAuth 2.0: