Class

The SessionManager is used to manage user sign in sessions.

Methods

MethodReturnsNotes
addFromCredential(credential, from, serverInfo?, oAuthInfo?)Promise<ArcGISIdentityManager>

Create a session from ArcGIS Maps SDK for JavaScript credential

clearSessions()void

Clear all sessions from session manager, the tokens are not be revoked

generateSeverSessionByPortalSession(portalSession, serverUrl, credentialsParamForGenerateToken)Promise<ArcGISIdentityManager>

Generate server session with owning system portal session.

generateToken(portalUrl, getTokenParam, credentialsParam)Promise<any>

Generate token.

getClientIdByUrl(portalUrl)string

Get a valid client id for portal url

getMainSession()ArcGISIdentityManager

Return main session.

getSessionByUrl(url)ArcGISIdentityManager

Return session by url.

getSessionKeyFromSession(session)string

Get session key from a session.

getSessions()ArcGISIdentityManager[]

Return all sessions.

getSessionType(session)SessionType

Return session type according to a session

getSignInErrorByCode(errorCode)SignInError

Get the sign-in error by providing the sign-in error code.

getSignInErrorCodeByAuthError(error)SignInErrorCode

Get the sign-in error by providing the authentication error.

handleAuthError(handleAuthErrorParams)Promise<ArcGISIdentityManager>

When you need to handle the error caused by sign in, you can catch the error and call this method. This method will try to sign in to get a new session if the 'gotoSignInDirectly' property is true. Otherwise, it will just handle the token error by different scenarios: 498: token invalided, go to system error page; token expired: show runtime error dialog to remind user to re-sign in; app item does not exist (item is deleted) or is inaccessible: show runtime error reminder.

isMainSession(session)boolean

Return true if the session is a main session and is valid.

isMainSessionExpired()boolean

Return true if the session is existed and is expired

isSameSession(session1, session2)boolean

Return true if the two sessions are equal.

isSignInPromptBlocked()boolean

return true if the sign-in prompt is blocked only effects on app env, always return false in builder env

isValidTokenFromStorage(portalUrl)Promise<boolean>

Sends a request to check the token of the session from storage.

nonOAuthSignIn(desUrl, forceLogin?)Promise<any>

Start non-OAuth sign in flow and return the user session. It use esri request to sign-in resource

removeSession(session)boolean

Remove the session from session manager and revoke token of session. So, deleting a session means signing out. Note: token of stand-alone server session will be destroyed when syncing to 'arcgis-dependency-extension'

signIn(signInParams)Promise<ArcGISIdentityManager>

Start OAuth2 sign-in flow and return the user session.

signInByResourceUrl(resourceUrl, owningSystemUrl?, forceLogin?)Promise<ArcGISIdentityManager>

Start sign in flow by a resource url and return the user session.

signOut(signOutParams)void

Start OAuth2 sign-out flow

signOutByResourceUrl(resourceUrl, owningSystemUrl?)void

Start a sign-out flow by a resource url without page redirects or refreshes

switchAccount(switchAccountParams)Promise<ArcGISIdentityManager>

Start OAuth2 switch account flow and return the user session.

switchAccountByResourceUrl(resourceUrl, owningSystemUrl?)Promise<ArcGISIdentityManager>

Start switch account flow by a resource url and return the user session.

useDialogToSetClientIdToConnectionsOfAppConfig(portalUrl)Promise<any>

Popup a dialog to set client id to app config

getInstance()SessionManager

Get singleton instance.

addFromCredential

Class Method
addFromCredential(credentialICredential | Credential, fromSessionChangedReasonType, serverInfo?ArcGISServerInfo, oAuthInfo?any): Promise<ArcGISIdentityManager>

Create a session from ArcGIS Maps SDK for JavaScript credential

Parameters
ParameterType
credentialICredential | Credential
fromSessionChangedReasonType
serverInfoArcGISServerInfo
oAuthInfoany
Returns 
Promise<ArcGISIdentityManager>

clearSessions

Class Method
clearSessions(): void

Clear all sessions from session manager, the tokens are not be revoked

Returns 
void

generateSeverSessionByPortalSession

Class Method
generateSeverSessionByPortalSession(portalSessionArcGISIdentityManager, serverUrlstring, credentialsParamForGenerateTokenstring): Promise<ArcGISIdentityManager>

Generate server session with owning system portal session.

Parameters
ParameterTypeDefaultNotes
portalSessionArcGISIdentityManager

A session of ArcGIS REST JS 'ArcGISIdentityManager' representing a logged in user.

serverUrlstring
credentialsParamForGenerateTokenstring'same-origin'
Returns 
Promise<ArcGISIdentityManager>

generateToken

Class Method
generateToken(portalUrlstring, getTokenParamstring, credentialsParamstring): Promise<any>

Generate token.

Parameters
ParameterTypeDefault
portalUrlstring
getTokenParamstring''
credentialsParamstring'same-origin'
Returns 
Promise<any>

getClientIdByUrl

Class Method
getClientIdByUrl(portalUrlstring): string

Get a valid client id for portal url

Parameters
ParameterTypeNotes
portalUrlstring

portal url

Returns 
string

getMainSession

Class Method
getMainSession(): ArcGISIdentityManager

Return main session.

The main session is session of the portal that the app connects to.

Returns 
ArcGISIdentityManager

ArcGIS REST JS 'ArcGISIdentityManager' representing a logged in user.

getSessionByUrl

Class Method
getSessionByUrl(urlstring): ArcGISIdentityManager

Return session by url.

Parameters
ParameterType
urlstring
Returns 
ArcGISIdentityManager

ArcGIS REST JS 'ArcGISIdentityManager' representing a logged in user.

getSessionKeyFromSession

Class Method
getSessionKeyFromSession(sessionArcGISIdentityManager): string

Get session key from a session.

Parameters
ParameterTypeNotes
sessionArcGISIdentityManager

A session of ArcGIS REST JS 'ArcGISIdentityManager' representing a logged in user.

Returns 
string

getSessions

Class Method
getSessions(): ArcGISIdentityManager[]

Return all sessions.

Returns 
ArcGISIdentityManager[]

Array of ArcGIS REST JS 'ArcGISIdentityManager' representing the logged in users.

getSessionType

Class Method
getSessionType(sessionArcGISIdentityManager): SessionType

Return session type according to a session

Parameters
ParameterType
sessionArcGISIdentityManager
Returns 
SessionType

getSignInErrorByCode

Class Method
getSignInErrorByCode(errorCodeSignInErrorCode): SignInError

Get the sign-in error by providing the sign-in error code.

Parameters
ParameterTypeDefaultNotes
errorCodeSignInErrorCodeSignInErrorCode.Other

The sign-in error code.

Returns 
SignInError

getSignInErrorCodeByAuthError

Class Method
getSignInErrorCodeByAuthError(errorany): SignInErrorCode

Get the sign-in error by providing the authentication error.

Parameters
ParameterTypeNotes
errorany

ArcGISRequestError or ArcGISAuthError

Returns 
SignInErrorCode

handleAuthError

Class Method
handleAuthError(handleAuthErrorParamsHandleAuthErrorParams): Promise<ArcGISIdentityManager>

When you need to handle the error caused by sign in, you can catch the error and call this method. This method will try to sign in to get a new session if the 'gotoSignInDirectly' property is true. Otherwise, it will just handle the token error by different scenarios: 498: token invalided, go to system error page; token expired: show runtime error dialog to remind user to re-sign in; app item does not exist (item is deleted) or is inaccessible: show runtime error reminder.

Parameters
ParameterType
handleAuthErrorParamsHandleAuthErrorParams
Returns 
Promise<ArcGISIdentityManager>

isMainSession

Class Method
isMainSession(sessionArcGISIdentityManager): boolean

Return true if the session is a main session and is valid.

Parameters
ParameterType
sessionArcGISIdentityManager
Returns 
boolean

isMainSessionExpired

Class Method
isMainSessionExpired(): boolean

Return true if the session is existed and is expired

Returns 
boolean

isSameSession

Class Method
isSameSession(session1ArcGISIdentityManager, session2ArcGISIdentityManager): boolean

Return true if the two sessions are equal.

Parameters
ParameterType
session1ArcGISIdentityManager
session2ArcGISIdentityManager
Returns 
boolean

isSignInPromptBlocked

Class Method
isSignInPromptBlocked(): boolean

return true if the sign-in prompt is blocked only effects on app env, always return false in builder env

Returns 
boolean

isValidTokenFromStorage

Class Method
isValidTokenFromStorage(portalUrlstring): Promise<boolean>

Sends a request to check the token of the session from storage.

Parameters
ParameterType
portalUrlstring
Returns 
Promise<boolean>

nonOAuthSignIn

Class Method
nonOAuthSignIn(desUrlstring, forceLogin?boolean): Promise<any>

Start non-OAuth sign in flow and return the user session. It use esri request to sign-in resource

Parameters
ParameterTypeNotes
desUrlstring

The url you want to sign in

forceLoginboolean
Returns 
Promise<any>

removeSession

Class Method
removeSession(sessionArcGISIdentityManager): boolean

Remove the session from session manager and revoke token of session. So, deleting a session means signing out. Note: token of stand-alone server session will be destroyed when syncing to 'arcgis-dependency-extension'

Parameters
ParameterTypeNotes
sessionArcGISIdentityManager

A session of ArcGIS REST JS 'ArcGISIdentityManager' representing a logged in user.

Returns 
boolean

signIn

Class Method
signIn(signInParamsSignInParams): Promise<ArcGISIdentityManager>

Start OAuth2 sign-in flow and return the user session.

Parameters
ParameterTypeDefaultNotes
signInParamsSignInParams{}

The properties for sign-in.

Returns 
Promise<ArcGISIdentityManager>

signInByResourceUrl

Class Method
signInByResourceUrl(resourceUrlstring, owningSystemUrl?string, forceLogin?boolean): Promise<ArcGISIdentityManager>

Start sign in flow by a resource url and return the user session.

Parameters
ParameterTypeNotes
resourceUrlstring

a resource url can be: service url: federated or non-federated; portal item url;

owningSystemUrlstring

owning system url for federated service url

forceLoginboolean
Returns 
Promise<ArcGISIdentityManager>

signOut

Class Method
signOut(signOutParamsSignOutParams): void

Start OAuth2 sign-out flow

Parameters
ParameterTypeDefaultNotes
signOutParamsSignOutParams{}

The properties for sign-out.

Returns 
void

signOutByResourceUrl

Class Method
signOutByResourceUrl(resourceUrlstring, owningSystemUrl?string): void

Start a sign-out flow by a resource url without page redirects or refreshes

Parameters
ParameterTypeNotes
resourceUrlstring

a resource url can be: service url: federated or non-federated; portal item url;

owningSystemUrlstring

owning system url for federated service url

Returns 
void

switchAccount

Class Method
switchAccount(switchAccountParamsSwitchAccountParams): Promise<ArcGISIdentityManager>

Start OAuth2 switch account flow and return the user session.

Parameters
ParameterTypeDefaultNotes
switchAccountParamsSwitchAccountParams{}

The properties for switching account.

Returns 
Promise<ArcGISIdentityManager>

switchAccountByResourceUrl

Class Method
switchAccountByResourceUrl(resourceUrlstring, owningSystemUrl?string): Promise<ArcGISIdentityManager>

Start switch account flow by a resource url and return the user session.

Parameters
ParameterTypeNotes
resourceUrlstring

a resource url can be: service url: federated or non-federated; portal item url;

owningSystemUrlstring

owning system url for federated service url

Returns 
Promise<ArcGISIdentityManager>

useDialogToSetClientIdToConnectionsOfAppConfig

Class Method
useDialogToSetClientIdToConnectionsOfAppConfig(portalUrlstring): Promise<any>

Popup a dialog to set client id to app config

Parameters
ParameterTypeNotes
portalUrlstring

portal url

Returns 
Promise<any>

getInstance

static
Class Method
getInstance(): SessionManager

Get singleton instance.

Returns 
SessionManager

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.