无法获得 app_installations 方法的授权
Can't have authorization for the app_installations methode
我正在开发一个 github 应用程序,我的实际任务是检索安装了该应用程序的 github 用户帐户/github 组织的列表。
所以基本上,我将使用 app_installations() Method in Github3.py 库。
此方法需要身份验证。所以通过运行下面的代码:
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()
我收到以下输出:
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
我应该提一下,我试图故意输入错误的密码,结果如预期的那样:
github3.exceptions.AuthenticationFailed: 401 Bad credentials
已解决问题!
我使用了错误的身份验证方法。
我应该使用 login_as_app(private_key_pem=key_file_pem, app_id=app_id) 而不是为了使用 app_installations() 方法。
我正在开发一个 github 应用程序,我的实际任务是检索安装了该应用程序的 github 用户帐户/github 组织的列表。 所以基本上,我将使用 app_installations() Method in Github3.py 库。 此方法需要身份验证。所以通过运行下面的代码:
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()
我收到以下输出:
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
我应该提一下,我试图故意输入错误的密码,结果如预期的那样:
github3.exceptions.AuthenticationFailed: 401 Bad credentials
已解决问题! 我使用了错误的身份验证方法。 我应该使用 login_as_app(private_key_pem=key_file_pem, app_id=app_id) 而不是为了使用 app_installations() 方法。