This action will force synchronization from 编程语言算法集/Python, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#!/usr/bin/env python3"""Created by sarathkaul on 14/11/19Updated by lawric1 on 24/11/20Authentication will be made via access token.To generate your personal access token visit https://github.com/settings/tokens.NOTE:Never hardcode any credential information in the code. Always use an environmentfile to store the private information and use the `os` module to get the informationduring runtime.Create a ".env" file in the root directory and write these two lines in that filewith your token::#!/usr/bin/env bashexport USER_TOKEN="""""from __future__ import annotationsimport osfrom typing import Anyimport requestsBASE_URL = "https://api.github.com"# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-userAUTHENTICATED_USER_ENDPOINT = BASE_URL + "/user"# https://github.com/settings/tokensUSER_TOKEN = os.environ.get("USER_TOKEN", "")def fetch_github_info(auth_token: str) -> dict[Any, Any]:"""Fetch GitHub info of a user using the requests module"""headers = {"Authorization": f"token {auth_token}","Accept": "application/vnd.github.v3+json",}return requests.get(AUTHENTICATED_USER_ENDPOINT, headers=headers).json()if __name__ == "__main__": # pragma: no coverif USER_TOKEN:for key, value in fetch_github_info(USER_TOKEN).items():print(f"{key}: {value}")else:raise ValueError("'USER_TOKEN' field cannot be empty.")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。