Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import json
import os
from googleapiclient import discovery
from oauth2client.service_account import ServiceAccountCredentials
def authenticated_directory_service(delegate_user_email):
""" Returns a service object for accessing the admin directory service.
json_creds = json.loads(os.environ['GOOGLE_KEYFILE_JSON'])
credentials = ServiceAccountCredentials.from_json_keyfile_dict(
credentials_delegated = credentials.create_delegated(delegate_user_email)
service ='admin', 'directory_v1', credentials=credentials_delegated)
return service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.