Token Expired - resin.auth.loginWithToken

Hi Y’all,

I’ve just started playing the the Node JS resin-sdk and have been using the resin.auth.loginWithToken call prior to querying a device, however I’m now hitting a Token Expired error. There doesn’t appear to be a way from the dashboard / profile to regenerate this token. Am I doing something wrong here? Is there a refresh token call?

Also I was passing the token in as a Fleet Service Variable, however the length of the key is borking the dashboard UI - the edit and delete icons get pushed off screen and the only workaround I’ve found is to remove the element from DOM.

Thanks in advance…
Chris!

Hi @chrisallmark Dashboard maintainer here!
The auth token that you can see in your preferences is automatically refreshed during normal dashboard usage. I believe the tokens are valid for 7 days.
We are currently working on implementing persistent API keys in the dashboard which will better enable programmatic implementations of the SDK.
The API keys are implemented on the SDK and our API, so if you’re feeling brave you can try the following:

Authenticate using your dashboard auth token and then generate an API key ( https://github.com/resin-io/resin-sdk/blob/master/DOCUMENTATION.md#authcreateapikeyname--promise )

resin.auth.loginWithToken(authToken)
.then(() => resin.auth.createApiKey('my_new_key'))
.then(function(apiKey) {
	console.log(apiKey);
});

Once you have your API key you can use as a direct replacement for your auth token without having to worry about it expiring.

I’ve added your report about the long variables to our issue queue and will get it fixed ASAP.

Hey @lucianbuzzo - that’s awesome thanks. I’ll give a spin later. :smile:

Hi,

We are happy to let you know that you can now create API keys that do not expire from the Dashboard.

These API keys are named tokens that can be created / revoked as needed, and they can be used for authentication in the resin.io API, CLI, and SDKs (Node.js Python)

For more information you can check the relevant section in our documents: https://docs.resin.io/learn/manage/account/#api-keys

Thanks!

Kostas

1 Like