API Tokens plugin for the Screwdriver API
const Hapi = require('@hapi/hapi');
const server = new Hapi.Server();
const tokensPlugin = require('./');
server.connection({ port: 3000 });
server.register({
register: tokensPlugin,
options: {}
}, () => {
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});
});
GET /tokens
POST /tokens
Arguments
name
- Name of the token. Names must be unique.description
- An optional description of what the token is used for.
Example payload:
{
"name": "Mobile Token",
"description": "Token for use by a mobile app"
}
PUT /tokens/{id}
Arguments
name
- Optional new name for the token. Names must be unique.description
- An optional description of what the token is used for.
Example payload:
{
"name": "A new name",
"description": "This is the same token as before, but with a new name and description"
}
PUT /tokens/{id}/refresh
DELETE /tokens/{id}
The server supplies factories to plugins in the form of server settings:
// handler tokenPlugin.js
handler: async (request, h) => {
const factory = request.server.app.tokenFactory;
// ...
}