Python Can';没有应用程序安装方法的授权
我正在开发一个github应用程序,我的实际任务是检索安装了该应用程序的github用户帐户/github组织的列表。 所以基本上,我将在库中使用这个方法。 此方法需要身份验证。因此,通过运行以下代码:Python Can';没有应用程序安装方法的授权,python,python-3.x,github-api,github3.py,Python,Python 3.x,Github Api,Github3.py,我正在开发一个github应用程序,我的实际任务是检索安装了该应用程序的github用户帐户/github组织的列表。 所以基本上,我将在库中使用这个方法。 此方法需要身份验证。因此,通过运行以下代码: def get_users(): user = "bilel.e***********" password = "5QPN74dHD******" gh = login(user, password) #gh is an instance of <
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()
修正问题!
我使用了错误的身份验证方法。
为了使用app\u installations()方法,我应该使用login\u as\u app(private\u key\u pem=key\u file\u pem,app\u id=app\u id)
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