A wrapper for the Major League Hacking (MLH) API.
Install with npm:
$ npm i mlh-api --save
Configuring the module:
const mlh = require('./index')
mlh.configure({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
redirectUri: 'YOUR_REDIRECT_URI'
})
Redirect your user to this url:
const url = mlh.authorizationCodeUrl(['your', 'scopes', 'here'])
Get the authorization code from the MLH callback to obtain an access token:
mlh.accessTokenFromAuthorizationCode(code).then(() => {
// Module is now configured with the access token
// Get user object
return mlh.user()
}).then(user => {
// Do stuff with user object
})
Redirect your user to this url:
const url = mlh.implicitAuthorizationUrl(['your', 'scopes', 'here'])
Set the access token from the MLH callback:
mlh.configure({ accessToken: token })
// Make user requests
mlh.users(1, 100).then(users => {
// Do stuff with users
})
Please visit the module documentation and the MLH API documentation for more information
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Tomer Aberbach