Authenticating REST APIs with Eve
Eve is a REST API server built in Python. We will test how to use Eve REST API framework with BasicAuth
, global authentication. Eve can also be started without any authentication at all, as a simple REST API server. This recipe is a simple demonstration of serving the entire web server. However, Eve provides more sophisticated and more role-based access control that protects certain APIs with roles for the users.
The server is started with a username and password, and the client passes on the base64
encode of the format username:password
to the server to get authenticated.
Getting ready
First install Eve using Python:
$ sudo pip install eve
This will install Eve, along with its dependencies, cerberus-0.9.2
, eve-0.7.4
, events-0.2.2
, flask-0.12
, flask-pymongo-0.5.1
, pymongo-3.4.0
, simplejson-3.11.1
, werkzeug-0.11.15
.
In this recipe, we will start a simple server with a username and password as the basic authentication.
How to do it...
First make sure that you have...