Javascript SDK Logout?

So I’ve got an app (html) that is using three legged authentication and have to do claiming and device setup using the ParticleJS SDK (as well as the softAP browser version). I can successfully login with either token or username and password, but can’t find any reference to do a logout. There’s a logout for iOS and Android that will clear the reference to the users session / access tokens, but nothing documented for Javascript. I’ve tried just running spark.logout(), but that just throws an error. Did I miss something?

I just refresh the page. Seems to work for me, although I’m not sure that’s how it was meant to be.

Yeah, that does work…but I’m doing a single page app. Think of it like using AngularJS where there are no page changes. In fact I may be switching it to Angular here soon.

Even though it’s not in the library, this appears to work. Can’t give guarantees that it’s elegant, or ‘the right way’ to do things, but until they get implemented properly, they might work.
Try putting the stuff below in a ‘logout’ function of your own, and see if it does what you need it to do :smile:

spark.accessToken = null;
spark.plugins = [];
spark.devices = {};
spark._attributeCache = null;
spark._events = null;

Works so far. No errors anyways. I’ll post back if I find anything else.

1 Like