prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  web_programming/fetch_github_info.py err
  <pre>message: Bad credentials. The API can&apos;t be accessed using username/password authentication. Please create a personal access token to access this endpoint: http://github.com/settings/tokens
  documentation_url: https://docs.github.com/articles/creating-a-personal-access-token-for-the-command-line
  </pre>
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `web_programming/fetch_github_info.py`
  Content:
  ```
  1 #!/usr/bin/env python3
  2 
  3 """
  4 Created by sarathkaul on 14/11/19
  5 
  6 Basic authentication using an API password is deprecated and will soon no longer work.
  7 Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth
  8 for more information around suggested workarounds and removal dates.
  9 """
  10 
  11 
  12 import requests
  13 
  14 _GITHUB_API = "https://api.github.com/user"
  15 
  16 
  17 def fetch_github_info(auth_user: str, auth_pass: str) -> dict:
  18     """
  19     Fetch GitHub info of a user using the requests module
  20     """
  21     return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json()
  22 
  23 
  24 if __name__ == "__main__":
  25     for key, value in fetch_github_info("<USER NAME>", "<PASSWORD>").items():
  26         print(f"{key}: {value}")
  27
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/web_programming/fetch_github_info.py b/web_programming/fetch_github_info.py
  --- a/web_programming/fetch_github_info.py
  +++ b/web_programming/fetch_github_info.py
  @@ -1,26 +1,50 @@
   #!/usr/bin/env python3
  -
   """
   Created by sarathkaul on 14/11/19
  +Updated by lawric1 on 24/11/20
   
  -Basic authentication using an API password is deprecated and will soon no longer work.
  -Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth
  -for more information around suggested workarounds and removal dates.
  -"""
  +Authentication 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 environment
  +file to store the private information and use the `os` module to get the information
  +during runtime.
   
  +Create a ".env" file in the root directory and write these two lines in that file
  +with your token::
  +
  +#!/usr/bin/env bash
  +export USER_TOKEN=""
  +"""
  +import os
  +from typing import Any, Dict
   
   import requests
   
  -_GITHUB_API = "https://api.github.com/user"
  +BASE_URL = "https://api.github.com"
   
  +# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user
  +AUTHENTICATED_USER_ENDPOINT = BASE_URL + "/user"
   
  -def fetch_github_info(auth_user: str, auth_pass: str) -> dict:
  +# https://github.com/settings/tokens
  +USER_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
       """
  -    return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json()
  -
  -
  -if __name__ == "__main__":
  -    for key, value in fetch_github_info("<USER NAME>", "<PASSWORD>").items():
  -        print(f"{key}: {value}")
  +    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 cover
  +    if 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.")
  
verification_info: {"golden_diff": "diff --git a/web_programming/fetch_github_info.py b/web_programming/fetch_github_info.py\n--- a/web_programming/fetch_github_info.py\n+++ b/web_programming/fetch_github_info.py\n@@ -1,26 +1,50 @@\n #!/usr/bin/env python3\n-\n \"\"\"\n Created by sarathkaul on 14/11/19\n+Updated by lawric1 on 24/11/20\n \n-Basic authentication using an API password is deprecated and will soon no longer work.\n-Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth\n-for more information around suggested workarounds and removal dates.\n-\"\"\"\n+Authentication will be made via access token.\n+To generate your personal access token visit https://github.com/settings/tokens.\n+\n+NOTE:\n+Never hardcode any credential information in the code. Always use an environment\n+file to store the private information and use the `os` module to get the information\n+during runtime.\n \n+Create a \".env\" file in the root directory and write these two lines in that file\n+with your token::\n+\n+#!/usr/bin/env bash\n+export USER_TOKEN=\"\"\n+\"\"\"\n+import os\n+from typing import Any, Dict\n \n import requests\n \n-_GITHUB_API = \"https://api.github.com/user\"\n+BASE_URL = \"https://api.github.com\"\n \n+# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user\n+AUTHENTICATED_USER_ENDPOINT = BASE_URL + \"/user\"\n \n-def fetch_github_info(auth_user: str, auth_pass: str) -> dict:\n+# https://github.com/settings/tokens\n+USER_TOKEN = os.environ.get(\"USER_TOKEN\", \"\")\n+\n+\n+def fetch_github_info(auth_token: str) -> Dict[Any, Any]:\n     \"\"\"\n     Fetch GitHub info of a user using the requests module\n     \"\"\"\n-    return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json()\n-\n-\n-if __name__ == \"__main__\":\n-    for key, value in fetch_github_info(\"<USER NAME>\", \"<PASSWORD>\").items():\n-        print(f\"{key}: {value}\")\n+    headers = {\n+        \"Authorization\": f\"token {auth_token}\",\n+        \"Accept\": \"application/vnd.github.v3+json\",\n+    }\n+    return requests.get(AUTHENTICATED_USER_ENDPOINT, headers=headers).json()\n+\n+\n+if __name__ == \"__main__\":  # pragma: no cover\n+    if USER_TOKEN:\n+        for key, value in fetch_github_info(USER_TOKEN).items():\n+            print(f\"{key}: {value}\")\n+    else:\n+        raise ValueError(\"'USER_TOKEN' field cannot be empty.\")\n", "issue": "web_programming/fetch_github_info.py err\n<pre>message: Bad credentials. The API can&apos;t be accessed using username/password authentication. Please create a personal access token to access this endpoint: http://github.com/settings/tokens\r\ndocumentation_url: https://docs.github.com/articles/creating-a-personal-access-token-for-the-command-line\r\n</pre>\n", "before_files": [{"content": "#!/usr/bin/env python3\n\n\"\"\"\nCreated by sarathkaul on 14/11/19\n\nBasic authentication using an API password is deprecated and will soon no longer work.\nVisit https://developer.github.com/changes/2020-02-14-deprecating-password-auth\nfor more information around suggested workarounds and removal dates.\n\"\"\"\n\n\nimport requests\n\n_GITHUB_API = \"https://api.github.com/user\"\n\n\ndef fetch_github_info(auth_user: str, auth_pass: str) -> dict:\n    \"\"\"\n    Fetch GitHub info of a user using the requests module\n    \"\"\"\n    return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json()\n\n\nif __name__ == \"__main__\":\n    for key, value in fetch_github_info(\"<USER NAME>\", \"<PASSWORD>\").items():\n        print(f\"{key}: {value}\")\n", "path": "web_programming/fetch_github_info.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\"\"\"\nCreated by sarathkaul on 14/11/19\nUpdated by lawric1 on 24/11/20\n\nAuthentication will be made via access token.\nTo generate your personal access token visit https://github.com/settings/tokens.\n\nNOTE:\nNever hardcode any credential information in the code. Always use an environment\nfile to store the private information and use the `os` module to get the information\nduring runtime.\n\nCreate a \".env\" file in the root directory and write these two lines in that file\nwith your token::\n\n#!/usr/bin/env bash\nexport USER_TOKEN=\"\"\n\"\"\"\nimport os\nfrom typing import Any, Dict\n\nimport requests\n\nBASE_URL = \"https://api.github.com\"\n\n# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user\nAUTHENTICATED_USER_ENDPOINT = BASE_URL + \"/user\"\n\n# https://github.com/settings/tokens\nUSER_TOKEN = os.environ.get(\"USER_TOKEN\", \"\")\n\n\ndef fetch_github_info(auth_token: str) -> Dict[Any, Any]:\n    \"\"\"\n    Fetch GitHub info of a user using the requests module\n    \"\"\"\n    headers = {\n        \"Authorization\": f\"token {auth_token}\",\n        \"Accept\": \"application/vnd.github.v3+json\",\n    }\n    return requests.get(AUTHENTICATED_USER_ENDPOINT, headers=headers).json()\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    if USER_TOKEN:\n        for key, value in fetch_github_info(USER_TOKEN).items():\n            print(f\"{key}: {value}\")\n    else:\n        raise ValueError(\"'USER_TOKEN' field cannot be empty.\")\n", "path": "web_programming/fetch_github_info.py"}]}