1
2
3
4
5
6
7
8
9
10
11
const info = new OAuthInfo({
// Swap this ID out with registered application IDappId: "q244Lb8gDRgWQ8hM",
// Uncomment the next line and update if using your own portal// portalUrl: "https://<host>:<port>/arcgis"// Uncomment the next line to prevent the user's signed in state from being shared with other apps on the same domain with the same authNamespace value.// authNamespace: "portal_oauth_inline",popup: false});
geosceneId.registerOAuthInfos([info]);
接下来,检查用户是否登录。
1
2
3
4
5
6
geosceneId
.checkSignInStatus(info.portalUrl + "/sharing")
.then(() => {
displayItems();
})
.catch(/*give user an option to sign in*/);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const portal = new Portal();
// Setting authMode to immediate signs the user in once loadedportal.authMode = "immediate";
// Once loaded, user is signed inportal.load().then(() => {
// Create query parameters for the portal searchconst queryParams = new PortalQueryParams({
query: "owner:" + portal.user.username,
sortField: "numViews",
sortOrder: "desc",
num: 20 });
// Query the items based on the queryParams created from portal above portal.queryItems(queryParams).then(createGallery);
});