Skip to content
Snippets Groups Projects

Clean up Google auth

Merged username-removed-652089 requested to merge auth-file into master
1 unresolved thread

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
21 print('No service account key file given, using the environment as-is.')
22 return GoogleCredentials.get_application_default()
23 previous_credentrials = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS')
24 with tempfile.NamedTemporaryFile('w') as f:
25 json.dump(secrets, f)
26 f.flush()
27 os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = f.name
28 credentials = GoogleCredentials.get_application_default()
29 if previous_credentrials is None:
30 del os.environ['GOOGLE_APPLICATION_CREDENTIALS']
31 else:
32 os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = previous_credentrials
33 return credentials
17 @contextmanager
18 def authed_service(auth):
19 with tempfile.NamedTemporaryFile() as auth_file:
  • Looks good to me 👌

  • Please register or sign in to reply
    Loading