-
Notifications
You must be signed in to change notification settings - Fork 901
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |