Avatar

How can I set the Javascript api object with a userName, database, and sessionId, not password?

0

The user is already authenticated and I have the credentials but not password. How can I create a Javascript GeotabAPI object with only this information as I can in in .NET?

Steve Hansen

Please sign in to leave a comment.

1 comment

Avatar
There's a couple of ways you can do this:
Quick and dirty is to set the option rememberMe:true and add some code that will add the credentials and server to local storage.
localStorage.setItem("geotabAPI_credentials", JSON.stringify(credentialsObject));
localStorage.setItem("geotabAPI_server", serverName);
The API object only supports browser local storage, so old browsers may not work with the rememberMe:true option. If needed, you can also override the "credentialsStore" object to point somewhere other than localStorage (ie. cookies) by implementing the object (get, set, and clear, as defined in the "defaultCredentialsStore" in the api.js file), and passing it into the GeotabApi() constructor as the 3rd argument. (see screen shot)
Javascript_API_-_stevehansen_geotab.png
0
Comment actions Permalink
Steve Hansen 0 votes