SessionManager

Class

The SessionManager is used to manage user sign in sessions.

Methods

MethodReturnsNotes
void

Clear all sessions

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

ArcGISIdentityManager

Return main session.

ArcGISIdentityManager

Return session by url.

string

Get session key from a session.

ArcGISIdentityManager[]

Return all sessions.

SignInError

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

SignInErrorCode

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

handleAuthError(error, popup)
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.

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.

signIn(signInParams)
Promise<ArcGISIdentityManager>

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

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

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

void

Sign out from main portal.

useDialogToSetClientIdToConnectiosOfAppConfigAndSignIn(portalUrl, needToSignIn?, serviceUrl?, forceLogin?)
Promise<any>

Popup a dialog to set client id to app config

Get singleton instance.

clearSessions

Class Method
clearSessions(): void

Clear all sessions

Returns 
void

generateSeverSessionByPortalSession

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

Generate server session with owning system portal session.

Parameters
ParameterTypeDefaultNotes
portalSession
ArcGISIdentityManager

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

serverUrl
string
credentialsParamForGenerateToken
string
'same-origin'
Returns 
Promise<ArcGISIdentityManager>

generateToken

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

Generate token.

Parameters
ParameterTypeDefault
portalUrl
string
getTokenParam
string
''
credentialsParam
string
'same-origin'
Returns 
Promise<any>

getClientIdByUrl

Class Method
getClientIdByUrl(portalUrlstring): string

Get a valid client id for portal url

Parameters
ParameterType
portalUrl
string
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
url
string
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
session
ArcGISIdentityManager

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.

getSignInErrorByCode

Class Method
getSignInErrorByCode(errorCodeSignInErrorCode): SignInError

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

Parameters
ParameterTypeDefaultNotes
errorCode
SignInErrorCode
SignInErrorCode.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
error
any

ArcGISRequestError or ArcGISAuthError

Returns 
SignInErrorCode

handleAuthError

Class Method
handleAuthError(errorany, popupboolean): 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.

Parameters
ParameterTypeDefault
error
any
popup
boolean
true
Returns 
Promise<ArcGISIdentityManager>

isValidTokenFromStorage

Class Method
isValidTokenFromStorage(portalUrlstring): Promise<boolean>

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

Parameters
ParameterType
portalUrl
string
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
desUrl
string

The url you want to sign in

forceLogin
boolean
Returns 
Promise<any>

removeSession

Class Method
removeSession(sessionArcGISIdentityManager): boolean

Remove the session from session manager.

Parameters
ParameterTypeNotes
session
ArcGISIdentityManager

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
signInParams
SignInParams
{}

The properties for sign in.

Returns 
Promise<ArcGISIdentityManager>

signInByResourceUrl

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

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

Parameters
ParameterTypeNotes
resourceUrl
string

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

owningSystemUrl
string

owning system url for federated service url

forceLogin
boolean
Returns 
Promise<ArcGISIdentityManager>

signOut

Class Method
signOut(): void

Sign out from main portal.

Returns 
void

useDialogToSetClientIdToConnectiosOfAppConfigAndSignIn

Class Method
useDialogToSetClientIdToConnectiosOfAppConfigAndSignIn(portalUrlstring, needToSignIn?boolean, serviceUrl?string, forceLogin?boolean): Promise<any>

Popup a dialog to set client id to app config

Parameters
ParameterTypeNotes
portalUrl
string

portal url

needToSignIn
boolean

indicates whether need to sign-in

serviceUrl
string

service url

forceLogin
boolean
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.