Tag: github api

Github API OAuth令牌validation

有什么办法来validation我的OAuth令牌的github API? “令牌”是指用户login到我的网站后得到的。 我使用cookie将其存储在客户端计算机上,但只检查是否有令牌是不够的:我需要实际检查令牌是否有效。 目前这需要我提出信息请求,然后捕捉错误。 然而,这是真正的损害我的利率和我的加载速度作为github API是sloooow …我使用Node.js,快递和octonode库。 我试着看github的API文档,但它们是微乎其微的。 也许这是关于OAuth,我不确定。 提前致谢。

access_token不存在于passport-github2请求中

我已经通过我的Github帐户注册了一个OAuth应用程序。 我基本上试图授权我的node请求(通过发送access_token作为请求cookie的一部分),所以我可以访问另一台服务器上的几个API。 因此我使用github-passport2软件包。 我已经设置了Github策略等等,似乎都是根据文档。 stream程也运作良好。 我的问题 login到Github(授权)并redirect回到我的/auth/github/callback , 理想情况下应该被授权,并且在req应该有一个access_token 。 但我没有! 因此,我无法使用access_token来授权我未来的请求。 需要注意的是,当从浏览器/客户端(使用withCredentials: true参数)发起请求时,此access_token自动附加。 通过节点相同的access_token似乎不可检索。 passport.use(new GitHubStrategy({ clientID: GITHUB_CLIENT_ID, clientSecret: GITHUB_CLIENT_SECRET, callbackURL: "http://localhost:8080/auth/github/callback", }, function(accessToken, refreshToken, profile, done) { // asynchronous verification, for effect… process.nextTick(function () { return done(null, profile); }); } )); app.get('/auth/github', passport.authenticate('github', { scope: [ 'user:email' ] }), function(req, res){ // The […]

Node.jsparsing器的链接头?

我正在使用Github API,它使用链接标题(在这里定义 )进行分页。 目前我只是使用一些string操作来提取“下一个”URL,但是我想知道是否有适合这个目的的模块(我在npm search中找不到任何东西)。 谢谢!

是否有可能查询GitHub API的任何回购,用户是一个合作者?

我似乎缺less,如果有可能查询Github的任何/所有回报,一个成员是一个合作者? 我正在写一个github oauth节点的应用程序,我试图得到,不仅是成员回购,但任何回购,他们是一个合作者。 这可能吗?

如何知道使用Github API时的MIMEtypes

我使用JS库( https://github.com/mikedeboer/node-github )来调用GitHub API: https : //developer.github.com/v3/repos/contents/从回购获取内容。 当返回types是'文件'时,我想知道它是MIMEtypes。 如果我将返回内容写入硬盘驱动器的文件中,有很多方法可以告诉mimetypes。 我的问题是如何知道mimetypes,而不必将其写入硬盘驱动器上的文件。

Github的Web API授权问题 – 返回“未find”

由于我没有发现任何人有同样的问题,我希望这是一件简单的事情。 我相当新鲜。 这是一个Node / Express应用程序,我正尝试连接到Githubs Web API并检索某个特定回购的问题。 我已经生成了一个个人令牌,并将其与基本授权一起使用。 当我尝试连接时,我得到:“ 未find ”。 Github的状态,authentication是必要的,他们返回404/403,我得到404,所以它必须与身份validation。 回购有问题。 令牌不应该有问题,我select“回购”作为访问范围。 其实我不知道我在做什么HTTP请求,但我已经尝试了请求和http。 所以除了别的以外,我想知道是否是授权标题是错误的。 我粘贴我现在使用请求的代码,并返回正文。 任何帮助是极大的赞赏。 const githubToken = process.env.TOKEN; let options = { url: "https://api.github.com/repos/myOrg/myRepo/issues/", headers: { "Authorization": "Basic " + githubToken, "User-Agent": "Mozilla/5.0", "Content-Type": "application/json" } }; let requestCB = function(error, response, body) { if (error) { console.log(error); } else if […]

如何通过API发布主旨(不是匿名的)

我正在使用passport-github策略。 passport.use(new Strategy({ clientID: "…", clientSecret: "…", callbackURL: 'http://localhost:3000/login/github/return', scope: 'gist' }, function(accessToken, refreshToken, profile, cb) { return cb(null, profile); })); 然后我发出POST请求 app.get('/profile/post', require('connect-ensure-login').ensureLoggedIn(), function(req, res){ var url = 'https://api.github.com/gists'; axios.post(url, { method: "POST", "description": "POSTING FROM EXPRESS", "public": true, "files": { "file1.txt": { "content": "EXPRESS " } } }) .then(function (response) {…}) .catch(function (error) […]

创build从CL与节点,JSONparsing错误的回购时Github API错误

创build一个节点CLI从CL创build回购站,发布到github api的问题。 我正在使用请求模块发布到github API。 request.post({ url: 'https://api.github.com/user/repos', headers:{ 'User-Agent': 'git CL – node', 'Content-type': 'application/json' }, auth:{ username: '-username-', password: '-password-' }, form:{ name: "a-new-repo" } }, function(err, res, body){ console.log(body); }); 我得到的错误是{"message":"Problems parsing JSON","documentation_url":"http://developer.github.com/v3"} 我已经尝试了很多东西,比如 设置多部分数据 而不是表单数据 设置内容types 作为JSON发送 我知道的事情是正确的 身份validation—我能够得到正确的答复,如果我做一个GET请求,它只是POST POSTpath和标题 链接请求模块 链接为github-api

使用Meteor访问github仓库中所有文件的名称

正如标题所说,我正在写一个meteor的Web应用程序,并试图访问github回购中的所有文件的名称。 我有一个Node github api包装器(它包装的实际api位于https://github.com/mikedeboer/node-github ),我能够成功地做一些其他的github api调用(即github。 repos.getAll和gethub.user.getFollowingFromUser)。 但是,出于某种原因,当我尝试使用github.repos.getContent时,无论我作为用户名还是回购传入,都会收到404错误。 所以这个工作: github.user.getFollowingFromUser( { user: "ndhoule" }, function(err, res) { console.log(JSON.stringify(res)); }); 但是这不是: github.repos.getContent( { user: "ndhoule", repo: "meteor-github-api" }, function(err, res){console.log(JSON.stringify(res)) }); 这是它产生的错误: I20141029-13:46:01.875(-5)? [error] { [Error: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}] I20141029-13:46:01.876(-5)? [error] message: '{"message":"Not Found","documentation_url":"https://developer.github.com/v3"}', I20141029-13:46:01.877(-5)? [error] code: 404 } null ndhoule I20141029-13:46:01.877(-5)? undefined 这种情况发生,无论我插入那里的用户名,所以我假设我以某种方式错误地使用getContent方法。 如果任何人都可以弄清楚我的错误是什么(或者可能提出了一个不同的方式来从meteor的回购文件中获取文件名),我将不胜感激这个帮助。 编辑:我试过指定一个path(即使这是一个可选的参数),我得到了一个稍微不同的结果。 修改后的代码: […]

如何将资源上传到node.js的github发行版

我正试图自动发布一些Github版本的资源,我编程创build。 这是我的上传function: function uploadFile(fileName, uploadUrl, callback){ var uploadEndPoint = url.parse(uploadUrl.substring(0,uploadUrl.indexOf('{'))); options.host = uploadEndPoint.hostname; options.path = uploadEndPoint.pathname+'?name=' + fileName; options.method = 'POST'; options.headers['content-type'] = 'application/zip'; var uploadRequest = https.request(options, callback); uploadRequest.on('error', function(e) { console.log('release.js – problem with uploadRequest request: ' + e.message); }); var readStream = fs.ReadStream(path.resolve(__dirname,'builds',fileName)); readStream.pipe(uploadRequest); readStream.on('close', function () { req.end(); console.log('release.js – ' […]