Spaces:
Running
Running
Download src/services/google_oauth.py from heisbuba/quantvat: direct link, hf CLI and curl.
- Browser
- Download file 929 Bytes
-
https://huggingface.co/spaces/heisbuba/quantvat/resolve/main/src/services/google_oauth.py
- Command line
-
hf download hf://spaces/heisbuba/quantvat/src/services/google_oauth.py
-
curl -L -o google_oauth.py https://huggingface.co/spaces/heisbuba/quantvat/resolve/main/src/services/google_oauth.py
929 Bytes
| import os | |
| from google_auth_oauthlib.flow import Flow | |
| FOLDER_MIME = 'application/vnd.google-apps.folder' | |
| def build_flow(scopes): | |
| """Create a Google OAuth flow for the given scopes.""" | |
| redirect_uri = os.environ.get("GOOGLE_REDIRECT_URI", "") | |
| if redirect_uri.startswith("http://"): | |
| os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' | |
| else: | |
| os.environ.pop('OAUTHLIB_INSECURE_TRANSPORT', None) | |
| os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] = '1' | |
| return Flow.from_client_config( | |
| client_config={ | |
| "web": { | |
| "client_id": os.environ.get("GOOGLE_CLIENT_ID"), | |
| "client_secret": os.environ.get("GOOGLE_CLIENT_SECRET"), | |
| "auth_uri": "https://accounts.google.com/o/oauth2/auth", | |
| "token_uri": "https://oauth2.googleapis.com/token", | |
| } | |
| }, | |
| scopes=scopes, | |
| redirect_uri=redirect_uri or None, | |
| ) | |