Session

You can use tm1web/api/session/session to retrieve information that is associated with the TM1 Web session. You can log in to, log out of, or retrieve information for a TM1 Web session.

Methods

login(params)
Performs a login to TM1 Web.
Parameters: params The login information object that uses one of the following object formats:
{
    adminHost: "localhost",
    tm1Server: "Planning Sample",
    username: "admin",
    password: "apple"
}

Or

{
    adminHost: "localhost",
    tm1Server: "Planning Sample",
    camPassport: "8sdf83uijsjdfsd903sd"
}

Or

{
    adminHost: "localhost",
    tm1Server: "Planning Sample",
    tm1SessionId: "D3​lJLw50uvh2jtbAc​IYyVA"
}
Returns dojo/promise/Promise as a promise that is resolved when the login action completes. If login fails, the promise is rejected, otherwise it is resolved. The promise is passed an object of the following format if login is successful.
{
    sessionToken: "7118fad5-bbeb-4b3e-8bea-4b4a45ca2735",
    tm1SessionId: "D3​lJLw50uvh2jtbAc​IYyVA",
    adminHost: "localhost",
    tm1Server: "Planning Sample",
     username: "Admin"
}
getInfo(sessionToken)
Retrieves the information that is associated with the TM1 Web session corresponding to the specified session token.
Parameters: sessionToken A session token corresponding to the TM1 Web session to retrieve information from.
Returns dojo/promise/Promise as a promise that is resolved when the action completes. If retrieval fails, the promise is rejected, otherwise it is resolved. The promise is passed an object of the following format if retrieval was successful.
{
    sessionToken: "7118fad5-bbeb-4b3e-8bea-4b4a45ca2735",
    tm1SessionId: "D3​lJLw50uvh2jtbAc​IYyVA",
    adminHost: "localhost",
    tm1Server: "Planning Sample",
    username: "Admin"
}
logout(sessionToken)
Performs a logout and invalidates the TM1 Web session corresponding to the specified session token.
Parameters: sessionToken A session token corresponding to the TM1 Web session to invalidate.
Returns dojo/promise/Promise as a promise that is resolved when the action completes. If retrieval fails, the promise is rejected, otherwise it is resolved. The action completes successfully even if the session does not exist or has already been invalidated.

For more information, see Dojo documentation for dijit._WidgetBase (https://dojotoolkit.org/reference-guide/1.10/dijit/_WidgetBase.html).

Examples

// login
require([
    "tm1web/api/session/session"
], function(session) {
    session.login({
	    adminHost: "localhost",
		tm1Server: "Planning Sample",
		username: "admin",
		password: "apple"
	}).then(function(sessionInfo) {
	    // Create Workbook or CubeViewer using sessionInfo.sessionToken
	}, function() {
	    // Handle login failure appropriately
	});
});
// getInfo
require([
    "tm1web/api/session/session"
], function(session) {
    session.getInfo("sessionToken").then(function(sessionInfo) {
	    // Continue using obtained sessionInfo
	});
});
// logout
require([
    "tm1web/api/session/session"
], function(session) {
    session.logout("sessionToken").then(function() {
	    // Logout has successfully completed
	});
});