Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
esride-nik committed Nov 16, 2022
0 parents commit 8eb712a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions jaspi_oauth2_snippet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const portalLogin = async (): Promise<void> => {
const oAuthInfo = new OAuthInfo({
appId: <appId>,
portalUrl: <arcgisServer> + endpoints.portal,
popup: false,
});

portal = new Portal({
url: <arcgisServer> + endpoints.portal,
});
await portal.load();

IdentityManager.registerOAuthInfos([oAuthInfo]);

try {
const signInEvt: Credential = await IdentityManager.checkSignInStatus(
`${oAuthInfo.portalUrl}${endpoints.sharing}`
);
userId = signInEvt.userId;
storeCredentialsInApp({ portal: portal, userId: userId });
} catch (error) {
console.error(error.message);
const signInEvt: Credential = await IdentityManager.getCredential(
`${oAuthInfo.portalUrl}${endpoints.sharing}`,
{
oAuthPopupConfirmation: false,
}
);
userId = signInEvt.userId;
storeCredentialsInApp({ portal: portal, userId: userId });
}
};

0 comments on commit 8eb712a

Please sign in to comment.