tomdyson / wagalytics

A Google Analytics dashboard in your Wagtail admin
MIT License
217 stars 42 forks source link

Error: [('PEM routines', 'PEM_read_bio', 'no start line')] #25

Open kyale-mwendwa opened 6 years ago

kyale-mwendwa commented 6 years ago

Hi I have run into a brick wall trying to get the wagtail anayltics to work. Followed the instructions on the page and I keep getting the following error while running it.

`[10/Apr/2018 15:53:41] "GET /admin/analytics/dashboard/ HTTP/1.1" 200 10119 Internal Server Error: /admin/analytics/token/ Traceback (most recent call last): File "E:\Python27\lib\site-packages\django\core\handlers\exception.py", line 42, in inner response = get_response(request)

File "E:\Python27\lib\site-packages\django\core\handlers\base.py", line 249, in _legacy_get_response response = self._get_response(request)

File "E:\Python27\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request)

File "E:\Python27\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "E:\Python27\lib\site-packages\django\views\decorators\cache.py", line 43, in _cache_controlled response = viewfunc(request, *args, **kw)

File "E:\Python27\lib\site-packages\wagtail\wagtailadmin\decorators.py", line 24, in decorated_view return view_func(request, *args, **kwargs)

File "E:\Python27\lib\site-packages\django\utils\decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs)

File "E:\Python27\lib\site-packages\wagalytics\views.py", line 41, in token access_token = get_access_token_from_str(settings.GA_KEY_CONTENT)

File "E:\Python27\lib\site-packages\wagalytics\views.py", line 33, in get_access_token_from_str keyDict, SCOPE)

File "E:\Python27\lib\site-packages\oauth2client\service_account.py", line 264, in from_json_keyfile_dict revoke_uri=revoke_uri)

File "E:\Python27\lib\site-packages\oauth2client\service_account.py", line 196, in _from_parsed_json_keyfile signer = crypt.Signer.from_string(private_key_pkcs8_pem)

File "E:\Python27\lib\site-packages\oauth2client_openssl_crypt.py", line 119, in from_string pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key)

File "E:\Python27\lib\site-packages\OpenSSL\crypto.py", line 2795, in load_privatekey _raise_current_error()

File "E:\Python27\lib\site-packages\OpenSSL_util.py", line 54, in exception_from_error_queue raise exception_type(errors)

Error: [('PEM routines', 'PEM_read_bio', 'no start line')]

[10/Apr/2018 15:53:45] "GET /admin/analytics/token/ HTTP/1.1" 500 18756`

danielmwai commented 6 years ago

@kyale-mwendwa @tomdyson am also getting this error please view it here at stackoverflow https://stackoverflow.com/questions/49898939/error-at-admin-analytics-token-exception-valuepem-routines-pem-read-bi?noredirect=1#comment86815089_49898939

cspollar commented 4 years ago

Until a fix is merged, editing the private key solves this issue. I've replaced \nwith\n. For local testing I've hardcoded these values in mysettings.py`.

# Sensitive Data Replaced with placeholder data.

GA_KEY_CONTENT = '{\
    "type": "service_account",\
    "project_id": "SOME-PROJECT-ID-123",\
    "private_key_id": "123",\
    "private_key": "-----BEGIN PRIVATE KEY-----\\n000000\\n111111\\n2222222\\n-----END PRIVATE KEY-----\\n",\
    "client_email": "example@example.iam.gserviceaccount.com",\
    "client_id": "123",\
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",\
    "token_uri": "https://oauth2.googleapis.com/token",\
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",\
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/EXAMPLE"\
}'
GA_VIEW_ID = 'ga:123'

These