Skip to content

Commit bc9577f

Browse files
committed
feat: Add Meet API quickstart
1 parent fd13d3d commit bc9577f

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

meet/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Additional samples can be found at https://github.com/googleapis/google-cloud-python/tree/main/packages/google-apps-meet

meet/quickstart/quickstart.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START meet_quickstart]
16+
from __future__ import print_function
17+
18+
import os.path
19+
20+
from google.auth.transport.requests import Request
21+
from google.oauth2.credentials import Credentials
22+
from google_auth_oauthlib.flow import InstalledAppFlow
23+
from google.apps import meet_v2
24+
25+
26+
# If modifying these scopes, delete the file token.json.
27+
SCOPES = ['https://www.googleapis.com/auth/meetings.space.created']
28+
29+
30+
def main():
31+
"""Shows basic usage of the Google Meet API.
32+
"""
33+
creds = None
34+
# The file token.json stores the user's access and refresh tokens, and is
35+
# created automatically when the authorization flow completes for the first
36+
# time.
37+
if os.path.exists('token.json'):
38+
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
39+
# If there are no (valid) credentials available, let the user log in.
40+
if not creds or not creds.valid:
41+
if creds and creds.expired and creds.refresh_token:
42+
creds.refresh(Request())
43+
else:
44+
flow = InstalledAppFlow.from_client_secrets_file(
45+
'credentials.json', SCOPES)
46+
creds = flow.run_local_server(port=0)
47+
# Save the credentials for the next run
48+
with open('token.json', 'w') as token:
49+
token.write(creds.to_json())
50+
51+
try:
52+
client = meet_v2.SpacesServiceClient(credentials=creds)
53+
request = meet_v2.CreateSpaceRequest()
54+
response = client.create_space(request=request)
55+
print(f'Space created: {response.meeting_uri}')
56+
except Exception as error:
57+
# TODO(developer) - Handle errors from Meet API.
58+
print(f'An error occurred: {error}')
59+
60+
61+
if __name__ == '__main__':
62+
main()
63+
# [END meet_quickstart]

meet/quickstart/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
google-apps-meet==0.1.6
2+
google-auth-httplib2==0.1.0
3+
google-auth-oauthlib==0.4.0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy