File: token.coffee
Defined in: | lib/resin/token |
Method Summary
-
~
(void)
saveToken(newToken, callback)
Save token
The token is saved to $(dataPrefix)/token, which usually equals to $HOME/.resin/token
resin.token.saveToken myToken, (error) -> throw error if error?
-
~
(void)
hasToken(callback)
Check if we have any token saved
resin.token.hasToken (hasToken) -> if hasToken console.log('It\'s there!') else console.log('It\'s not there!')
-
~
(void)
getToken(callback)
Get saved token value
resin.token.getToken (error, token) -> throw error if error? if token? console.log("My token is: #{token}")
-
~
(void)
clearToken(callback)
Remove token from the filesystem
resin.token.clearToken (error) -> throw error if error?
Method Details
~
(void)
saveToken(newToken, callback)
TODO:
We should make the token more secure
Note:
The token is saved as plain text.
Save token
The token is saved to $(dataPrefix)/token, which usually equals to $HOME/.resin/token
resin.token.saveToken myToken, (error) -> throw error if error?
~
(void)
hasToken(callback)
Check if we have any token saved
resin.token.hasToken (hasToken) -> if hasToken
console.log('It\'s there!') else
console.log('It\'s not there!')
~
(void)
getToken(callback)
Note:
If the key doesn't exist, undefined and no error is returned
Get saved token value
resin.token.getToken (error, token) -> throw error if error? if token?
console.log("My token is: #{token}")
~
(void)
clearToken(callback)
Note:
If the token doesn't exist, no action is performed
Remove token from the filesystem
resin.token.clearToken (error) -> throw error if error?