Skip to content

Commit 36d6b27

Browse files
committed
Allow for unauthenticated requests
Fixes gh-187
1 parent 2373a36 commit 36d6b27

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,17 @@ var github = new Github({
5757
});
5858
```
5959

60-
You can use either:
60+
Some information, such as public Gists, can be accessed without any authentication. For such use cases, you can create
61+
a Github instance as follows:
62+
63+
```js
64+
var github = new Github();
65+
```
66+
67+
In conclusion, you can use:
6168
* Authorised App Tokens (via client/secret pairs), used for bigger applications, created in web-flows/on the fly
6269
* Personal Access Tokens (simpler to set up), used on command lines, scripts etc, created in GitHub web UI
70+
* No authorization
6371

6472
See these pages for more info:
6573

dist/github.bundle.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.bundle.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
// -------------
4444

4545
var Github = function (options) {
46+
options = options || {};
47+
4648
var API_URL = options.apiUrl || 'https://api.github.com';
4749

4850
// HTTP Request Abstraction

test/test.auth.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ describe('Github constructor', function() {
2323
});
2424
});
2525

26+
describe('Github constructor without authentication data', function() {
27+
it('should read public information', function(done) {
28+
var github = new Github();
29+
var gist = github.getGist('f1c0f84e53aa6b98ec03');
30+
31+
gist.read(function(err, res, xhr) {
32+
should.not.exist(err);
33+
xhr.should.be.instanceof(XMLHttpRequest);
34+
res.should.be.an('object');
35+
36+
done();
37+
});
38+
});
39+
});
40+
2641
describe('Github constructor (failing case)', function() {
2742
before(function() {
2843
github = new Github({

0 commit comments

Comments
 (0)