๋ด github ์ฑ์ ์ฌ์ฉํ์ฌ oauth๋ฅผ ์ํํ ๋ค์ ์ธ์ฆ๋ ์ฌ์ฉ์ ์ ์ฅ์ ๋ฐ ์กฐ์ง์ ์ฝ์ผ๋ ค๊ณ ํฉ๋๋ค. ๊ทธ๋ฌ๋ "์ฌ์ฉ์๋ฅผ ์ํ ์ค์น ๋์ด", "์ค์น๋ฅผ ์ํด ์ฌ์ฉ์๊ฐ ์ก์ธ์คํ ์ ์๋ ์ ์ฅ์ ๋์ด" ๋ฐ ๊ธฐํ ์ฌ๋ฌ ์๋ํฌ์ธํธ์ ๊ด๋ จ๋ ์ฟผ๋ฆฌ์ ๊ฒฝ์ฐ ๋์ผํ pygithub API๋ฅผ ์ป์ ์ ์์ต๋๋ค.
์ฐธ์กฐ ๋งํฌ : http://pygithub.readthedocs.io/en/latest/apis.html
์ถ์ . ์ด์ ์๋ oauth ์ฑ์ ์ฌ์ฉํ๊ณ ์์๊ณ ํ๋ฆ์ ์ํํ ์ ์์์ต๋๋ค. ์ด์ ๋ ์นํ ์ ๊ตฌ๋ ํด์ผ ํ๋ ์ด๋ฒคํธ๋ ์์ ํด์ผ ํ๋ฏ๋ก github ์ฑ์ผ๋ก ์ ํํ์ต๋๋ค.
์์ ํ๊ณ ์ถ์ต๋๋ค.
์ด ๊ธฐ๋ฅ์ ๋งค์ฐ ์ ์ฉํ ๊ฒ์ ๋๋ค :+1:
์ด๊ฒ์ #1021์์ ๋ค๋ฃจ์ง๋ง ์น์ธ/๋ณํฉ์ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ต๋๋ค. @sfdye ์ฐ๋ฆฌ๊ฐ ๊ทธ๊ฒ์ ๋ณผ ์ ์์ต๋๊น?
auth_token์ ์ป์ผ๋ ค๋ฉด:
`
์ค์น_url = " https://github.com/api/v3/app/installations "
์ค์น_์๋ต = ์์ฒญ.get(์ค์น_URL, ํค๋=ํค๋, ์ธ์ฆ=CustomJWTAuth())
Installations_response.raise_for_status()
for item in installations_response.json():
installation_id = item['id']
#print (installation_id)
access_tokens_url = "https://github.com/api/v3/app/installations/{installation_id}/access_tokens".format(
installation_id=installation_id)
access_tokens_response = requests.post(access_tokens_url, headers=headers, auth=CustomJWTAuth())
access_tokens_response.raise_for_status()
#print (access_tokens_response.json())
token = access_tokens_response.json()['token']
#print (token)
#return github3.login(token=token)
return token
raise Exception("No app installations")
`
https://pypi.org/project/github-bot-api/ ๋ฅผ ํ์ธํ์ญ์์ค. GitHub ์ฑ ๋ฐ ํด๋น ์ค์น๋ฅผ ์ํ PyGithub ํด๋ผ์ด์ธํธ๋ฅผ ์ ๊ณตํฉ๋๋ค. (๋ฉด์ฑ ์กฐํญ: ์ ๋ ํด๋น ํจํค์ง์ ์์ฑ์์ ๋๋ค)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์์ ํ๊ณ ์ถ์ต๋๋ค.