Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Add form urlencoded header to requests to bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
janjongboom committed Aug 23, 2012
1 parent 58a8abf commit 656d141
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion bitbucket/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ var Request = exports.Request = function(options) {
var headers = {
'Host':'api.bitbucket.org',
"User-Agent": "NodeJS HTTP Client",
"Content-Length": "0"
"Content-Length": "0",
"Content-Type": "application/x-www-form-urlencoded"
};
var getParams = httpMethod != "POST" ? parameters : {};
var postParams = httpMethod == "POST" ? parameters : {};
Expand Down
27 changes: 17 additions & 10 deletions demo/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var oauth = new OAuth(
secrets.oauth.clientId, //consumerKey,
secrets.oauth.secret, //consumerSecret,
"1.0", //version,
"http://node-bitbucket.fjakobs.c9.io/bitbucket/callback", //authorize_callback,
"http://localhost:" + PORT + "/bitbucket/callback", //authorize_callback,
'HMAC-SHA1' //signatureMethod,
);

Expand Down Expand Up @@ -49,17 +49,24 @@ getOAuthRequestToken(function(error, oauthToken, oauthTokenSecret, results) {
res.end();
return;
}

var onError = function (err) {
res.writeHead(500);
res.end(JSON.stringify(err));
};

// use API
bitbucket.getEmailApi().getAll(function (err, emails) {
if (err) return onError(err);

bitbucket.getSshApi().getKeys(function (err, keys) {
if (err) return onError(err);

// use API
repo.getUserRepos(secrets.username, function(err, user) {
if (err) {
res.writeHead(err.status);
res.end(JSON.stringify(err));
return;
}
res.writeHead(200);
res.end(JSON.stringify(user));
res.writeHead(200);
res.end("Emails: " + JSON.stringify(emails) + ", Keys: " + keys.length);
});
});

return;
}
// URL called by bitbucket after authenticating
Expand Down

0 comments on commit 656d141

Please sign in to comment.