如何抑制谷歌日历API流输出Python3



我想知道如何抑制Google流输出,使我的输出更加干净。

这是Quickstart.py代码:

creds =None
if os.path.exists('token.pickle'):
first_time_login = False
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)

# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
first_time_login = True
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
# Building the resource Calendar
service = build('calendar', 'v3', credentials=creds)

当你运行这个代码时,你会在终端上得到以下输出:

请访问此URL以授权此应用程序:https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=504506216880-4sanqellgo5ovampvrngut6q4e4pr09a.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A4617%2F&scope=https%3A%2F%2Fww.googleapis.com%2Fat%2Fcalendar&state=J7Id4IqIKyER5hykiGhfRcL9HZVejs&access_type=离线

我希望在运行上述代码时根本没有输出。

请在谷歌日历API上获取quickstart.py,如果有帮助,请点击此链接:

https://developers.google.com/calendar/quickstart/python

这是不可能的,因为快速启动中的授权流是为命令行应用程序设计的,如快速启动说明:

本例中的授权流是为命令行应用程序设计的。有关如何在web应用程序中执行授权的信息,请参阅将OAuth 2.0用于web服务器应用程序。

最新更新