2017-09-21 1 views

답변

2

G Suite Email Audit API은 여전히 ​​Google Data API protocol을 사용하는 이전 API 중 하나입니다. 이 프로토콜은 google-api-python-client에서 지원되지 않지만 대신 gdata-python-client을 사용해야합니다. 이 라이브러리는 오래되어 구글은 더 이상 업데이트되지 않습니다

  • 를 그것은 단지 당신이 여기

oauth2client 라이브러리를 통합하는 데 필요한으로 OAuth2 인증을 수행하기 위해 파이썬 2.x에서와

  • 를 작동 그것을 사용하는 방법에 대한 예제 : 당신이 구글에서 원래 샘플을 원하는 경우

    from __future__ import print_function 
    
    import argparse 
    
    import gdata.apps.audit.service 
    from oauth2client import file, client, tools 
    
    SCOPES = ['https://apps-apis.google.com/a/feeds/compliance/audit/',] 
    
    # be sure to update with the correct user 
    ID = '[email protected]' 
    
    store = file.Storage('email-audit{}.json'.format(ID)) 
    creds = store.get() 
    
    # client_id.json is the client_id file generated from the developer console project 
    if not creds or creds.invalid: 
        flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() 
        flags.auth_host_port = [8010, 8020] 
        flow = client.flow_from_clientsecrets('client_id.json', SCOPES) 
        creds = tools.run_flow(flow, store, flags) 
    
    access_token, expires_in = creds.get_access_token() 
    
    gd_client = gdata.apps.audit.service.AuditService(domain=ID.split('@')[1]) 
    gd_client.additional_headers[u'Authorization'] = u'Bearer {0}'.format(access_token) 
    
    monitors = gd_client.getEmailMonitors(ID.split('@')[0]) 
    
    print(monitors) 
    

    , 당신은 그것을 here 찾을 수 있습니다. 그것은 내 것보다 훨씬 복잡하며 OAuth2 인증을 수행하지 않기 때문에 작동 할 것입니다. 참조로 사용하십시오.

  • 관련 문제