Remote User Logins

📘

Remote user logins require an account in a Knack app with an email/password combination. SSO is not supported with remote user logins.

If you want to make view-based API calls as a logged-in user from your server-side code, where you won't be able to use our JavaScript utility functions to get a user's token, you can log that user in remotely with a POST request to the following route with the user's email address and password included in the JSON payload:
https://api.knack.com/v1/applications/<app_id>/session

A full remote login request would look like the following (be sure to change YOUR-APP-ID to your application ID):

curl -H "Content-Type: application/json" \
     --data '{"email":"email address","password":"password"}' \
     "https://api.knack.com/v1/applications/YOUR-APP-ID/session"

Your response will look like the following, where you will want to store the value of token in a variable to use to authenticate your view-based requests.

// Data returned by remote login request
{
  "session": {
    "user": {
      "approval_status": "approved",
      "empty_pass": false,
      "id": "user_id",
      "profile_keys": [
        "profile_4"
      ],
      "profile_objects": [
        {
          "entry_id": "entry_id",
          "object": "object_4"
        }
      ],
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiNTUzMWExNmI2YTEzMTk1ZTcyNmUxZTBmIiwiYXBwbGljYXYpb25faWQiOiI1NTIzMTM5ZjNiY2U2NDdhMDJiZDUxNTAiLCJpYXQiOjE0Mjk3MTgzNzl9.K-WULiJxT-st8vxnTkqxCtp2nv5ykrSToPQsTRx6r1I",
      "utility_key": "key",
      "values": {}
    }
  }
}

Using the token we got from the response to our remote login request, we can now authenticate our view-based requests like so:

# Sample authenticated request
curl -H "Content-Type: application/json"
     -H "X-Knack-Application-Id: YOUR-APP-ID"
     -H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiNTUzMWExNmI2YTEzMTk1ZTcyNmUxZTBmIiwiYXBwbGljYXYpb25faWQiOiI1NTIzMTM5ZjNiY2U2NDdhMDJiZDUxNTAiLCJpYXQiOjE0Mjk3MTgzNzl9.K-WULiJxT-st8vxnTkqxCtp2nv5ykrSToPQsTRx6r1I"
     https://api.knack.com/v1/pages/scene_1/views/view_1/records

What’s Next