Token Manager Server
Token Manager Server is a server based on Restify created to manage authorization tokens.
Installation
npm install token-manager-server
QuickStart
var TokenManagerServer = TokenManagerServer server = ; //starts a server in port 8000
You can also embed the service in you own restify app like this:
var restify = tokenManagerServer = server = restify; /* bodyParser and queryParser are required */ server; server; tokenManagerServer; // register get and post /myTokenEndpoint
API
GET /token?tokenString=
Returns a json containing a token data. The format is like this:
- Status code 200:
"clientId": "someclientid" "tokenString": "sometokenstring" "roles":
- Status code 404:
{
"code": "ResourceNotFound",
"message": "Some error message here"
}
POST /token
The client should send an application/json data containing the following:
"clientId": "someclientid" "tokenString": "sometokenstring" "expiration": 60000 "roles": "client" "admin"
The expiration time should be set in milliseconds. The server returns like this:
- Status code 200:
"clientId": "someclientid" "tokenString": "sometokenstring"
- Status code 400:
"code": "InvalidContent" "message": "Some error message here"
Standalone Server
bash >$ sudo npm install -g token-manager-server
The installation of the module gives you an path executable called token-manager-server, that simply bootstraps a server, running in a specified port.
bash >$ token-manager-server 8080
This command will start a server in port 8000. If no port is specified, port 3000 will be used.