The user session token (legacy) or a refresh token (JMap Cloud)
Optional
organizationId: stringThe JMap Cloud organization id
// Set the user session token
JMap.User.setToken("v1.MRq [.....] Rehef72YWws","my-organization-id")
.then(userData => {
console.log(`Session token = "${userData.accessToken}""`)
console.log(`The session belongs to ${userData.user.fullName}`)
})
.catch(error => {
if (error === "user.token.invalid") {
console.log(`Invalid token`)
} else {
console.log(`Server error`)
}
})
JMap.User.setToken
Sets the user session data. Useful if you want to make a call to our Rest API and set the session token by yourself.
Calling this method will acctivate JCoreOptions.legacyAuthentication
You need to fetch a refresh token from the JMap Cloud Rest API, and pass this refresh token, along with the optional organisation Id, to the JMap.User.setToken method. Beware that a refresh token can only be used once, it is invalidated afterward
Fetching data from a REST API can be done with the curl command-line tool (https://curl.haxx.se/docs/)
will return something like: