Skip to content

Commit db09b75

Browse files
Update github.py
1 parent 3acb661 commit db09b75

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

consuming-apis-python/github.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import requests
22

3-
# First, make sure to follow the steps to create your own Github application:
3+
# First, make sure to follow the steps to create your own GitHub application:
44
# https://docs.github.com/en/free-pro-team@latest/developers/apps/creating-an-oauth-app
55

66

@@ -13,7 +13,7 @@
1313
REDIRECT_URI = "<REPLACE_WITH_REDIRECT_URI>"
1414

1515

16-
# In this method you'll ask the Github API for a URL to redirect the user
16+
# In this method you'll ask the GitHub API for a URL to redirect the user
1717
# for authentication.
1818
def create_oauth_link():
1919
params = {
@@ -23,13 +23,13 @@ def create_oauth_link():
2323
"response_type": "code",
2424
}
2525

26-
# This endpoint is defined in the Github documentation:
26+
# This endpoint is defined in the GitHub documentation:
2727
# https://docs.github.com/en/free-pro-team@latest/developers/apps/authorizing-oauth-apps#1-request-a-users-github-identity
2828
endpoint = "https://github.com/login/oauth/authorize"
2929

3030
response = requests.get(endpoint, params=params)
3131

32-
# When you make the request above, Github will redirect you to their
32+
# When you make the request above, GitHub will redirect you to their
3333
# website to input your credentials. Since you're doing this
3434
# programmatically, you need to get the `url` parameter and print it in
3535
# the console instead.
@@ -38,7 +38,7 @@ def create_oauth_link():
3838
return url
3939

4040

41-
# In this method you'll exchange the code you got from the Github API with
41+
# In this method you'll exchange the code you got from the GitHub API with
4242
# an access token.
4343
def exchange_code_for_access_token(code=None):
4444
params = {
@@ -52,7 +52,7 @@ def exchange_code_for_access_token(code=None):
5252
# In this case – JSON.
5353
headers = {"Accept": "application/json"}
5454

55-
# This endpoint is defined in the Github documentation:
55+
# This endpoint is defined in the GitHub documentation:
5656
# https://docs.github.com/en/free-pro-team@latest/developers/apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github
5757
endpoint = "https://github.com/login/oauth/access_token"
5858

@@ -67,7 +67,7 @@ def print_user_info(access_token=None):
6767
# when calling the API.
6868
headers = {"Authorization": f"token {access_token}"}
6969

70-
# This endpoint is defined in the Github documentation:
70+
# This endpoint is defined in the GitHub documentation:
7171
# https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user
7272
endpoint = "https://api.github.com/user"
7373

@@ -87,10 +87,10 @@ def print_user_info(access_token=None):
8787
# So, one last time, step by step:
8888
# 1. Create a link to redirect the user to for authentication:
8989
link = create_oauth_link()
90-
print(f"Follow the link to start the authentication with Github: {link}")
90+
print(f"Follow the link to start the authentication with GitHub: {link}")
9191

92-
# 2. Paste the code you got from Github after authenticating
93-
code = input("Github code: ")
92+
# 2. Paste the code you got from GitHub after authenticating
93+
code = input("GitHub code: ")
9494

9595
# 3. Exchange that code with an access token
9696
access_token = exchange_code_for_access_token(code)

0 commit comments

Comments
 (0)