Skip to content

Instantly share code, notes, and snippets.

@PaulMougel
Last active June 7, 2017 19:17
Show Gist options
  • Save PaulMougel/c2cbd337af98b5b36a50c84c33ac5e0b to your computer and use it in GitHub Desktop.
Save PaulMougel/c2cbd337af98b5b36a50c84c33ac5e0b to your computer and use it in GitHub Desktop.
How to use bell for JIRA
// You'll need to create a hapi.js server
//
// For more information about tokens, check
// https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-oauth-authentication
var jiraStrategy = require('./jira.strategy');
server.auth.strategy('jira', 'bell', {
provider: strategy('https://xxx.atlassian.net'),
password: 'COOKIE-PASSWORD',
clientId: 'CLIENT-ID',
clientSecret: 'CLIENT-SECRET'
});
server.route({
method: '*',
path: '/bell/jira',
config: {
auth: {
strategy: 'jira',
mode: 'try'
},
handler: function (request, reply) {
reply(request.auth);
}
}
});
module.exports = function (baseUrl) {
return {
protocol: 'oauth',
auth: baseUrl + '/plugins/servlet/oauth/authorize',
token: baseUrl + '/plugins/servlet/oauth/access-token',
temporary: baseUrl + '/plugins/servlet/oauth/request-token',
signatureMethod: 'RSA-SHA1',
profile: function (credentials, params, get, callback) {
get(baseUrl + '/rest/api/2/myself', {}, function (profile) {
credentials.profile = profile;
callback();
});
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment