Reputation: 161
I'm working on a github application and my actual task is to retrieve list of github user account / github organization on which the app has been installed. So basically, I'll be using the app_installations() Method in Github3.py Library. This method require authentication. So by running the following code :
def get_users():
user = "bilel.e***********"
password = "5QPN74dHD******"
gh = login(user, password)
#gh is an instance of <class 'github3.github.GitHub'>
scopes = ['user', 'repo']
auth = gh.authorize(user, password, scopes)
ghi = gh.app_installations()
return ()
get_users()
I receive the following output :
Traceback (most recent call last):
File "ghe-admin-app/service.py", line 33, in <module>
get_users()
File "ghe-admin-app/service.py", line 29, in get_users
auth = gh.authorize(user, password, scopes)
File "/usr/local/lib/python3.7/dist-packages/github3/github.py", line 503, in authorize
json = self._json(self._post(url, data=data), 201)
File "/usr/local/lib/python3.7/dist-packages/github3/models.py", line 156, in _json
raise exceptions.error_for(response)
github3.exceptions.UnprocessableEntity: 422 Validation Failed
I should mention that I tried to put a wrong password on purpose and the result was as expected :
github3.exceptions.AuthenticationFailed: 401 Bad credentials
Upvotes: 0
Views: 56
Reputation: 161
Fixed issue ! I was using the wrong Authentication method. I should use login_as_app(private_key_pem=key_file_pem, app_id=app_id) instead in order to use the app_installations() method.
Upvotes: 1