1
我正在尝试编写客户端Javascript分叉给定GitHub回购。我正在使用OAuth.io服务获取API范围设置为“public_repo”和“repo”的OAuth令牌。使用客户端JavaScript和OAuth.io与GitHub API分拣回购
我使用github.js访问GitHub的API,使用fork
方法(在makeWebsite
功能):
$(document).ready(function() {
initializeOAuth();
setEventListener();
});
var setEventListener = function() {
$("#button").click(popupOAuth);
};
var initializeOAuth = function() {
OAuth.initialize("rG-ChpeD0zdiIPoJpK58gN4qMJQ");
};
var popupOAuth = function() {
OAuth.popup("github").done(makeWebsite);
};
var makeWebsite = function(result) {
var token = result["token"];
var github = new Github({
token: token,
auth: "oauth"
});
var repo = github.getRepo("michael", "github");
repo.fork(function(err) {
console.log(err);
});
};
当我运行这段代码并完成OAuth的舞蹈,我得到以下错误:
是否*任何* GitHub API调用适合您?任何破坏性的API调用? – Konklone 2014-09-01 15:50:35
是的。 'repo.show(function(err,myRepo){console.log(myRepo);});'把我所有的[this](https://gist.github.com/adelevie/6dcf1b03ccfb0d407d00)。这让我觉得有一个范围问题。 – user94154 2014-09-01 15:53:45