This repository was archived by the owner on Jan 4, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed
Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -39,16 +39,25 @@ def __call__(self, r):
3939 r .headers ['Authorization' ] = 'bearer {}' .format (self .generate_token ())
4040 return r
4141
42- with open (os .environ ['PRIVATE_KEY_FILE' ]) as fp :
43- private_pem = fp .read ()
4442
45- authorization = JWTAuth (
46- iss = os .environ ['APP_ID' ],
47- key = private_pem )
43+ def read_private_key ():
44+ with open (os .environ ['PRIVATE_KEY_FILE' ]) as fp :
45+ private_key = fp .read ()
46+ return private_key
4847
49- response = requests .get ('https://api.github.com/app' ,
50- auth = authorization ,
51- headers = dict (accept = 'application/vnd.github.machine-man-preview+json' ))
5248
53- # Print the response
54- print (response .json ())
49+ def authenticate ():
50+ authorization = JWTAuth (
51+ iss = os .environ ['APP_ID' ],
52+ key = read_private_key ())
53+
54+ response = requests .get ('https://api.github.com/app' ,
55+ auth = authorization ,
56+ headers = dict (accept = 'application/vnd.github.machine-man-preview+json' ))
57+
58+ return response
59+
60+
61+ if __name__ == '__main__' :
62+ import pprint
63+ pprint .pprint (authenticate ().json ())
You can’t perform that action at this time.
0 commit comments