Auth

balena.auth : object

Kind: static namespace


authenticate

balena.auth.authenticate(credentials)Promise

You should use login when possible, as it takes care of saving the token and email as well.

Notice that if credentials contains extra keys, they'll be discarted by the server automatically.

Kind: static method of auth Summary: Authenticate with the server Access: protected Fulfil: String - session token

Param
Type
Description

credentials

Object

in the form of email, password

credentials.email

String

the email

credentials.password

String

the password

Example

balena.auth.authenticate(credentials).then(function(token) {
	console.log('My token is:', token);
});

getActorId

balena.auth.getActorId()Promise

This will only work if you used login or loginWithToken to log in.

Kind: static method of auth Summary: Get current logged in actor id Access: public Fulfil: Number - actor id Example


getToken

balena.auth.getToken()Promise

This will only work if you used login to log in.

Kind: static method of auth Summary: Get current logged in user's raw API key or session token Access: public Fulfil: String - raw API key or session token Example


getUserInfo

balena.auth.getUserInfo()Promise

This will only work if you used login to log in.

Kind: static method of auth Summary: Get current logged in user's info Access: public Fulfil: Object - user info Example


isLoggedIn

balena.auth.isLoggedIn()Promise

Kind: static method of auth Summary: Check if you're logged in Access: public Fulfil: Boolean - is logged in Example


login

balena.auth.login(credentials)Promise

If the login is successful, the token is persisted between sessions.

Kind: static method of auth Summary: Login Access: public

Param
Type
Description

credentials

Object

in the form of email, password

credentials.email

String

the email

credentials.password

String

the password

Example


loginWithToken

balena.auth.loginWithToken(authToken)Promise

Login to balena with a session token or api key instead of with credentials.

Kind: static method of auth Summary: Login with a token or api key Access: public

Param
Type
Description

authToken

String

the auth token

Example


logout

balena.auth.logout()Promise

Kind: static method of auth Summary: Logout Access: public Example


register

balena.auth.register(credentials)Promise

Kind: static method of auth Summary: Register a user account Access: public Fulfil: String - session token

Param
Type
Description

credentials

Object

in the form of username, password and email

credentials.email

String

the email

credentials.password

String

the password

[credentials.'g-recaptcha-response']

String | undefined

the captcha response

Example


requestVerificationEmail

balena.auth.requestVerificationEmail()Promise

This will only work if you used login to log in.

Kind: static method of auth Summary: Re-send verification email to the user Access: public Example


verifyEmail

balena.auth.verifyEmail(verificationPayload)Promise

Kind: static method of auth Summary: Verifies an email Access: public Fulfil: String - session token

Param
Type
Description

verificationPayload

Object

in the form of email, and token

verificationPayload.email

String

the email

verificationPayload.token

String

the verification token

Example


whoami

balena.auth.whoami()Promise

This will only work if you used login or loginWithToken to log in.

Kind: static method of auth Summary: Return current logged in information Access: public Fulfil: (Object|undefined) - actor information, if it exists Example


twoFactor

balena.auth.twoFactor : object

Kind: static namespace of auth


challenge

balena.auth.twoFactor.challenge(code)Promise

You should use login when possible, as it takes care of saving the token and email as well.

Kind: static method of twoFactor Summary: Challenge two factor authentication and complete login Access: public

Param
Type
Description

code

String

code

Example


disable

balena.auth.twoFactor.disable(password)Promise

Disables two factor authentication.

Kind: static method of twoFactor Summary: Disable two factor authentication Access: public Fulfil: String - session token

Param
Type
Description

password

String

password

Example


enable

balena.auth.twoFactor.enable(code)Promise

Enables two factor authentication.

Kind: static method of twoFactor Summary: Enable two factor authentication Access: public Fulfil: String - session token

Param
Type
Description

code

String

code

Example


getSetupKey

balena.auth.twoFactor.getSetupKey()Promise

Retrieves a setup key for enabling two factor authentication.

Kind: static method of twoFactor Summary: Get two factor authentication setup key Access: public Fulfil: String - setup key Example


isEnabled

balena.auth.twoFactor.isEnabled()Promise

Kind: static method of twoFactor Summary: Check if two factor authentication is enabled Access: public Fulfil: Boolean - whether 2fa is enabled Example


isPassed

balena.auth.twoFactor.isPassed()Promise

Kind: static method of twoFactor Summary: Check if two factor authentication challenge was passed Access: public Fulfil: Boolean - whether 2fa challenge was passed Example


verify

balena.auth.twoFactor.verify(code)Promise

Verifies two factor authentication. Note that this method not update the token automatically. You should use challenge when possible, as it takes care of that as well.

Kind: static method of twoFactor Summary: Verify two factor authentication Access: public Fulfil: String - session token

Param
Type
Description

code

String

code

Example


Last updated

Was this helpful?