aboutsummaryrefslogtreecommitdiffstats
path: root/github3/core.py
blob: 6221f9ee171521bde36c5b71bcc5afaa6fc35717 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-

"""
github3.core
~~~~~~~~~~~~

This module provides the entrance point for the GitHub3 module.
"""

__version__ = '0.0.0'
__license__ = 'MIT'
__author__ = 'Kenneth Reitz'


import envoy

from .api import Github, settings



def no_auth():
    """Returns an un-authenticated Github object."""

    gh = Github()

    return gh


def basic_auth(username, password):
    """Returns an authenticated Github object, via HTTP Basic."""

    gh = Github()
    gh.is_authenticated = True
    gh.session.auth = (username, password)

    return gh



# def git_config():
#     """Returns an authenticated Github object, via HTTP Basic.

#     GitHub API token is taken from `git config`.
#     """

#     username = envoy.run('git config github.user').std_out.strip()
#     token = envoy.run('git config github.token').std_out.strip()

#     def enable_auth(*args, **kwargs):
#         kwargs['auth'] = (username, token)
#         return args, kwargs

#     gh = Github()
#     gh.is_authenticated = True
#     gh._requests_pre_hook = enable_auth

#     return gh