@@ -28,11 +28,11 @@ def mkdirs(path):
28
28
29
29
class Octodir (object ):
30
30
31
- def __init__ (self , folder_url , output_folder ):
31
+ def __init__ (self , folder_url , output_folder , api_key ):
32
32
super (Octodir , self ).__init__ ()
33
33
self .folder_url = folder_url
34
34
self .output_folder = output_folder
35
-
35
+ self . headers = { "Authorization" : f"Token { api_key } " }
36
36
self .repo = None
37
37
self .target_dir = None
38
38
self .branch = None
@@ -48,7 +48,7 @@ def __get_raw_url(self, file_path, url):
48
48
49
49
def __get_repo_tree (self ):
50
50
api = requests .get (
51
- api_urls .recursive .format (self .repo , self .branch )).text
51
+ api_urls .recursive .format (self .repo , self .branch ), headers = self . headers ).text
52
52
files = json .loads (api )
53
53
54
54
output = []
@@ -91,7 +91,7 @@ def __scrutinize_url(self, folder_url):
91
91
def __api_response (self ):
92
92
repo_data = self .__scrutinize_url (self .folder_url )
93
93
api = requests .get (api_urls .no_recursive .format (
94
- repo_data .repo , repo_data .branch )).text
94
+ repo_data .repo , repo_data .branch ), headers = self . headers ).text
95
95
response = json .loads (api )
96
96
97
97
return response
0 commit comments