@@ -21,7 +21,7 @@ Please submit issues and pull requests, help out, or just give encouragement.
21
21
22
22
- [ Library Demos] ( http://github.directcode.org/demos/ )
23
23
- [ Pub Package] ( https://pub.dartlang.org/packages/github )
24
- - [ Wiki] ( https://github.com/DirectMyFile /github.dart/wiki )
24
+ - [ Wiki] ( https://github.com/SpinlockLabs /github.dart/wiki )
25
25
- [ Latest API reference] ( https://pub.dev/documentation/github/latest/ )
26
26
27
27
## Getting Started
@@ -30,36 +30,49 @@ First, add the following to your pubspec.yaml:
30
30
31
31
``` yaml
32
32
dependencies :
33
- github : ^5 .0.0
33
+ github : ^6 .0.0
34
34
` ` `
35
35
36
36
Then import the library
37
37
38
- For the browser use:
39
38
` ` ` dart
40
- import 'package:github/browser.dart';
41
- ```
42
-
43
- and for the server or Flutter use:
44
- ``` dart
45
- import 'package:github/server.dart';
39
+ import 'package:github/github.dart';
46
40
```
47
41
48
42
and then use it:
49
43
50
44
** Example**
51
45
``` dart
52
- import 'package:github/browser.dart';
53
-
54
- void main() async {
55
- /* Create a GitHub Client */
56
- var github = createGitHubClient();
46
+ import 'package:github/github.dart';
47
+
48
+ Future<void> main() async {
49
+ /* Create a GitHub Client, with anonymous authentication by default */
50
+ var github = GitHub();
51
+
52
+ /* or Create a GitHub Client and have it try to find your token or credentials automatically
53
+ In Flutter and in server environments this will search environment variables in this order
54
+ GITHUB_ADMIN_TOKEN
55
+ GITHUB_DART_TOKEN
56
+ GITHUB_API_TOKEN
57
+ GITHUB_TOKEN
58
+ HOMEBREW_GITHUB_API_TOKEN
59
+ MACHINE_GITHUB_API_TOKEN
60
+ and then GITHUB_USERNAME and GITHUB_PASSWORD
61
+
62
+ In a browser it will search keys in the same order first through the query string parameters
63
+ and then in window sessionStorage
64
+ */
65
+ var github = GitHub(auth: findAuthenticationFromEnvironment());
57
66
58
67
/* or Create a GitHub Client using an auth token */
59
- var github = createGitHubClient(auth: new Authentication.withToken("YourTokenHere"));
68
+ var github = GitHub(auth: new Authentication.withToken("YourTokenHere"));
69
+
70
+ /* or Create a GitHub Client using a username and password */
71
+ var github = GitHub(auth: new Authentication.basic('username', 'password'));
60
72
61
73
Repository repo = await github.repositories.getRepository(new RepositorySlug("user_or_org", "repo_name"));
62
74
/* Do Something with repo */
75
+
63
76
}
64
77
```
65
78
0 commit comments