1
votes

I am getting this error while trying to get the analytics report using python script.I have don exacly the same in "https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py".

File "HelloAnalytics.py", line 108, in <module>
    main()
  File "HelloAnalytics.py", line 102, in main
    service_account_email)
  File "HelloAnalytics.py", line 31, in get_service
    service_account_email, key_file_location, scopes=scope)
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/service_account.py", line 334, in from_p12_keyfile
    token_uri=token_uri, revoke_uri=revoke_uri)
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/service_account.py", line 291, in _from_p12_keyfile_contents
    private_key_password)
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/_openssl_crypt.py", line 116, in from_string
    pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key)
OpenSSL.crypto.Error: [('PEM routines', 'PEM_read_bio', 'no start line')]
1
Please copy / paste your code here. Because first, maybe you don't really done the same thing, second: Nobody likes to follow links, finally: If this link gone down SO will keep code. - Arount
Please paste the code as text into your question then highlight and press Ctrl+K this allows us to copy and paste your code into our IDEs and help identify the problem. Please read how to create a Minimal, Complete, Verifiable example to know what code you need to include - WhatsThePoint
Also post your platform you are developing on, as OSX's built in python has some issues with crypto working with google-api-python-client. something to do with the six module. - Matt
Thanx for the reply..I am using exactly the same in ubuntu os havin 2.7 python.developers.google.com/analytics/devguides/reporting/core/v3/…. only changing the service_account_email = '[email protected]' and key_file_location = 'client_secrets.json'.I am unable to paste the whole code.some word restriction is showing for me - Vivek

1 Answers

0
votes

It appears you selected to download the json file not the p12. The v3 example is a little bit out dated, Analytics Reporting API V4 is more up to date. but you code can easily be adjusted for .json file by replacing:

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

with this

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    KEY_FILE_LOCATION, SCOPES)