Skip to content

Commit

Permalink
feat: Add Meet API quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrrrl committed Mar 5, 2024
1 parent fd13d3d commit bc9577f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions meet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Additional samples can be found at https://github.com/googleapis/google-cloud-python/tree/main/packages/google-apps-meet
63 changes: 63 additions & 0 deletions meet/quickstart/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START meet_quickstart]
from __future__ import print_function

import os.path

from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.apps import meet_v2


# If modifying these scopes, delete the file token.json.
SCOPES = ['https://www.googleapis.com/auth/meetings.space.created']


def main():
"""Shows basic usage of the Google Meet API.
"""
creds = None
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
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.json', 'w') as token:
token.write(creds.to_json())

try:
client = meet_v2.SpacesServiceClient(credentials=creds)
request = meet_v2.CreateSpaceRequest()
response = client.create_space(request=request)
print(f'Space created: {response.meeting_uri}')
except Exception as error:
# TODO(developer) - Handle errors from Meet API.
print(f'An error occurred: {error}')


if __name__ == '__main__':
main()
# [END meet_quickstart]
3 changes: 3 additions & 0 deletions meet/quickstart/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
google-apps-meet==0.1.6
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.0

0 comments on commit bc9577f

Please sign in to comment.