Mbuso
Mbuso

Reputation: 141

How to suppress the google calender API flow output Python3

I would like to know how to suppress the Google flow output to make my output more clean.

Here is the Quickstart.py code:

    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)

When you run this code you get the below output on terminal:

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=504506216880-4sanqellgo5ovampvrngut6q4e4pr09a.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A46171%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar&state=J7Id4IqIKyER5hykiGhfRcL9HZVejs&access_type=offline

I want there to be no output at all when I run the above code.

Please get the quickstart.py on google calender API or follow this link if it helps:

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

Upvotes: 0

Views: 85

Answers (1)

Kessy
Kessy

Reputation: 1994

This can't be done since the authorization flow in the quick-start is designed for a command-line application as mentioned on the quick-start Notes:

The authorization flow in this example is designed for a command-line application. For information on how to perform authorization in a web application, see Using OAuth 2.0 for Web Server Applications.

Upvotes: 1

Related Questions