jquery - Gist/Github API - 获取私有(private)和公共(public) Gist

标签 jquery github-api gist

我正在尝试使用 github api 列出一组用户的所有要点。这工作得很好,但我似乎无法让它为我自己或任何其他用户返回私有(private)要点。

我知道您可以在请求中设置范围,但我不知道如何在 JQuery 请求中设置它以及我应该使用什么范围来获取私有(private)要点?

我的一些代码如下:

var the_url = 'https://api.github.com/users/'+ encodeURIComponent(user) +'/gists';

      $.oauth ({
        consumerKey: 'xxxxxxxxxxxxxxxxx', 
        consumerSecret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 
        type: "GET",
        url: the_url,
        data: {},
        dataType: 'json',
        async: false,

最佳答案

您需要用户通过 oAuth 授予访问权限。

You can read public gists and create them for anonymous users without a token; however, to read or write gists on a user’s behalf the gists oAuth scope is required.

http://developer.github.com/v3/oauth/#scopes

关于jquery - Gist/Github API - 获取私有(private)和公共(public) Gist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10219804/

相关文章:

javascript - 每次状态改变时如何在 ReactJS 中重做 API 调用?

api - GitHub API : Get email addresses of all members of organization

github - 是否有gist文件最新版本的永久链接?

javascript - 通过 AJAX 加载页面并执行 javascript 和 CSS

bash - 如何通过命令行更新 GitHub 上拉取请求中的第一条评论?

javascript - 有效地使用 setInterval/clearInterval

Github - 如何通过 API 搜索要点?

github - 如果删除 fork 的 Gist 会发生什么?

jQuery 日期选择器多选和取消选择

javascript - jqGrid userData 在 View 中显示值(asp.net mvc3)