Skip to main content

Facility Login

info

Before you continue, make sure you have a valid facility account. See Create a Facility Account for more information.

Currently, the admin for the facility can login through the following methods:

  1. Password and Email
  2. Magic Link

1. Password and Email Login

Password and Email login is the most common login method. It requires the admin to enter their email and password. If the admin has OTP enabled, they will also need to enter their OTP code.

Let's look at the two types of login.

1a. Login With Password and Email (No OTP)

This is the normal sign-in process. The admin enters their email and password, your app sends a request to the server, and the server returns a token. The token can be used to authenticate the admin for subsequent requests.

query FacilitySignIn($email: String!, $password: String!) {
facilitySignIn(email: $email, password: $password) {
token
id
email
adminName
otpEnabled
otpStatus
}
}

Variables:

{
"email": "admin_email",
"password": "admin_password"
}

Response

{
"data": {
"facilitySignIn": {
"token": "login_token",
"id": "facility_id",
"email": "admin_email",
"adminName": "admin_name",
"otpEnabled": false,
"otpStatus": null
}
}
}

1b. Login With Password and Email (With OTP)

If the admin has OTP enabled, they will also need to enter their OTP code. The server will return an OTP token instead of the regular login token. The admin will need to verify and complete the sign-in process using the OTP token and an OTP code.

info

To setup OTP, see Setup OTP.

1b.1. Normal Sign-In will return an OTP token.

query FacilitySignIn($email: String!, $password: String!) {
facilitySignIn(email: $email, password: $password) {
token
id
}
}

Variables:

{
"email": "admin_email",
"password": "admin_password"
}

Response

{
"data": {
"facilitySignIn": {
"token": "otp_token",
"id": "facility_id"
}
}
}

Note that the token returned is an OTP token (Prefix with otp_). The admin will need to enter the OTP code to complete the sign-in process.

1b.2. Complete OTP Sign-In

query FacilityVerifySignInWithOtpCode($otpCode: String!, $signInOtpToken: String!) {
facilityVerifySignInWithOtpCode(otpCode: $otpCode, signInOtpToken: $signInOtpToken) {
id
token
}
}

Variables:

{
"otpCode": "123456",
"signInOtpToken": "otp_SomeOtpToken"
}

The admin will then receive a response with the token that can be used to authenticate the admin for subsequent requests.

Response

{
"data": {
"facilityVerifySignInWithOtpCode": {
"id": "facility_id",
"token": "login_token"
}
}
}