Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sheets/quickstart/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ def main():
flow = InstalledAppFlow.from_client_secrets_file(
"credentials.json", SCOPES
)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
# Set the port to a fixed number.
creds = flow.run_local_server(port=8080)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Setting a fixed port like 8080 can lead to port conflicts if another application is already using this port on the user's machine. While port=0 allows the system to choose an available port, using a fixed port might require users to manually resolve conflicts. Consider adding a mechanism to check port availability or fall back to a dynamic port if 8080 is in use, or at least document this potential issue for users.

# Save the credentials for the next run.
with open("token.json", "w") as token:
token.write(creds.to_json())

try:
service = build("sheets", "v4", credentials=creds)

# Call the Sheets API
# Call the Sheets API.
sheet = service.spreadsheets()
result = (
sheet.values()
Expand Down
Loading