Gist / Github API - 获取私人和公共要点 [英] Gist / Github API - get private and public Gists
问题描述
我正在尝试使用github api列出来自一组用户的所有要点。这工作得很好,但我似乎无法让它为自己或任何其他用户返回私人要点。
I am trying to list all gist from a group of users using the github api. This is working really well but I can't seem to get it to return private gists for myself or any others users.
我知道您可以在请求中设置范围,但我不知道如何在我的JQuery请求中设置这个范围以及我应该使用什么范围来获取私有要点?
I know that you can set scope in the request but I don't get how I would set this in my JQuery request and what scope should I use to get private gists?
我的一些代码如下:
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'll need a user to grant access via oAuth.
您可以在没有令牌的情况下阅读公共要点并为匿名用户创建它们;但是,要代表用户读取或写入要点,需要提供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/#范围
这篇关于Gist / Github API - 获取私人和公共要点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!