python类from_p12_keyfile()的实例源码

api.py 文件源码 项目:django-torina-blog 作者: naritotakizawa 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def initialize_analyticsreporting():
    """Initializes an analyticsreporting service object.

    Returns:   analytics an authorized analyticsreporting service
    object.

    """

    credentials = ServiceAccountCredentials.from_p12_keyfile(
        settings.SERVICE_ACCOUNT_EMAIL, settings.KEY_FILE_LOCATION,
        scopes=SCOPES
    )

    http = credentials.authorize(httplib2.Http())

    # Build the service object.
    analytics = build('analytics', 'v4', http=http,
                      discoveryServiceUrl=DISCOVERY_URI)

    return analytics
utils.py 文件源码 项目:gee-gateway 作者: openforis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def initialize(ee_account='', ee_key_path='', ee_user_token=''):
    try:
        if ee_user_token:
            credentials = OAuth2Credentials(ee_user_token, None, None, None, None, None, None)
            ee.InitializeThread(credentials)
        elif ee_account and ee_key_path:
            credentials = ServiceAccountCredentials.from_p12_keyfile(
                service_account_email=ee_account,
                filename=ee_key_path,
                private_key_password='notasecret',
                scopes=ee.oauth.SCOPE + ' https://www.googleapis.com/auth/drive')
            ee.Initialize(credentials)
        else:
            ee.Initialize()
    except (EEException, TypeError):
        pass
ga_report.py 文件源码 项目:DjangoDashboard 作者: jialinzou 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def initialize_analyticsreporting():
  """Initializes an analyticsreporting service object.

  Returns:
    analytics an authorized analyticsreporting service object.
  """

  credentials = ServiceAccountCredentials.from_p12_keyfile(
    SERVICE_ACCOUNT_EMAIL, KEY_FILE_LOCATION, scopes=SCOPES)

  http = credentials.authorize(httplib2.Http())

  # Build the service object.
  analytics = build('analytics', 'v4', http=http, discoveryServiceUrl=DISCOVERY_URI)

  return analytics
accountList.py 文件源码 项目:pyGACustomDimensions 作者: analyticsftw 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_service(api_name, api_version, scope, key_file_location,
                service_account_email):
  """Get a service that communicates to a Google API.

  Args:
    api_name: The name of the api to connect to.
    api_version: The api version to connect to.
    scope: A list auth scopes to authorize for the application.
    key_file_location: The path to a valid service account p12 key file.
    service_account_email: The service account email address.

  Returns:
    A service that is connected to the specified API.
  """

  credentials = ServiceAccountCredentials.from_p12_keyfile(
    service_account_email, key_file_location, scopes=scope)

  http = credentials.authorize(httplib2.Http())

  # Build the Google API service object.
  service = build(api_name, api_version, http=http)

  return service
exportAllCustomDimensionsCSV.py 文件源码 项目:pyGACustomDimensions 作者: analyticsftw 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_service(api_name, api_version, scope, key_file_location, service_account_email):
  credentials = ServiceAccountCredentials.from_p12_keyfile(service_account_email, key_file_location, scopes=scope)
  http = credentials.authorize(httplib2.Http())
  service = build(api_name, api_version, http=http)
  return service
updateAllCustomDimensions.py 文件源码 项目:pyGACustomDimensions 作者: analyticsftw 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_service(api_name, api_version, scope, key_file_location,
                service_account_email):

  credentials = ServiceAccountCredentials.from_p12_keyfile(service_account_email, key_file_location, scopes=scope)
  http = credentials.authorize(httplib2.Http())

  # Build the Google API service object.
  service = build(api_name, api_version, http=http)

  return service
fillAllCustomDimensions.py 文件源码 项目:pyGACustomDimensions 作者: analyticsftw 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_service(api_name, api_version, scope, key_file_location, service_account_email):

  credentials = ServiceAccountCredentials.from_p12_keyfile(service_account_email, key_file_location, scopes=scope)
  http = credentials.authorize(httplib2.Http())

  # Build the Google API service object.
  service = build(api_name, api_version, http=http)
  return service
importCSV.py 文件源码 项目:pyGACustomDimensions 作者: analyticsftw 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_service(api_name, api_version, scope, key_file_location, service_account_email):
  credentials = ServiceAccountCredentials.from_p12_keyfile(service_account_email, key_file_location, scopes=scope)
  http = credentials.authorize(httplib2.Http())
   # Build the Google API service object.
  service = build(api_name, api_version, http=http)
  return service


问题


面经


文章

微信
公众号

扫码关注公众号