Link Search Menu Expand Document

REST Authentication

Table of Contents

  1. Introduction
  2. Endpoints

Introduction

The WiFi Pineapple REST API will only accept requests that are sent with a valid token. Currently, the only way to generate a token is to login as the user. API Token generation is a planned feature.

foxtrot@intent:~$ curl -X POST http://172.16.42.1:1471/api/login -d '{"username": "root", "password": "test"}'
{"token":"eyJVc2VyIjoicm9vdCIsIkV4cGlyeSI6IjIwMjAtMDUtMTdUMTg6NDM6NTEuNjg1NjA5NTJaIn0=.VZpkUmWREeLMtKGx0wZFeWczj8hImbPnulTT5zpnQpM="}
foxtrot@intent:~$

The API endpoint responds with an error for invalid credentials, or a token on success. The token can then be used to make other API requests.

foxtrot@intent:~$ curl -X PUT http://172.16.42.1:1471/api/notifications -H "Authorization: Bearer eyJVc2VyIjoicm9vdCIsIkV4cGlyeSI6IjIwMjAtMDUtMTdUMTg6NDM6NTEuNjg1NjA5NTJaIn0=.VZpkUmWREeLMtKGx0wZFeWczj8hImbPnulTT5zpnQpM=" -d '{"level": 0, "message": "Hello World!"}'
{"success":true}
foxtrot@intent:~$
foxtrot@intent:~$ curl -X GET http://172.16.42.1:1471/api/notifications -H "Authorization: Bearer eyJVc2VyIjoicm9vdCIsIkV4cGlyeSI6IjIwMjAtMDUtMTdUMTg6NDM6NTEuNjg1NjA5NTJa
In0=.VZpkUmWREeLMtKGx0wZFeWczj8hImbPnulTT5zpnQpM="  
[{"id":1,"message":"Hello World!","level":0,"time":"2020-09-18T10:30:21.031669675Z","read":false,"displayed":false,"module_name":""}]
foxtrot@intent:~$

Endpoints

Obtain an authentication token.

Request Body

{
    "username": string,
    "password": string,
}

Response

If successful, returns authentication token:
{
    "token": string
}
If unsuccessful: See REST Error Responses