Google API access using Service Account oauth2client.client.CryptoUnavailableError: No crypto library available

送分小仙女□ 提交于 2019-11-28 09:47:57

That error probably means you need the python-openssl package.

apt-get install python-openssl

This did the trick for me (without converting to PEM):

pip install PyOpenSSL

pip freeze says I have version 0.15.1

Even if you are installed pycrypto & python-ssl libraries in your development environment, You need to add this pycrypto library in your application's app.yaml file.

libraries:
- name: pycrypto
  version: "latest"

I just recently set this up but opted to go with PyCrypto 2.6.1, but you can also use python-openssl as mentioned in the previous answer.

The only problem I had and I can't pinpoint this down, but the P12 key generated by the Google Developer Console wasn't working with my Service Account API call (to the Content API for Shopping), and I had to switch the key to the PEM format to get things going.

My setup: (Win7, python 2.7.x, PyCrypto 2.6.1)

The error I got when trying to use the P12 key, but later resolved when converting it to PEM:

Error 3: PKCS12 format is not supported by the PyCrypto library. NotImplementedError: PKCS12 format is not supported by the PyCrypto library. Try converting to a “PEM” (openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > privatekey.pem) or using PyOpenSSL if native code is an option.

One important thing, don't forget to go inside Google Analytics and grant the appropriate permissions for the client email address that is created during the creation of the Service Account.

OSX 10.11 El Capitan does not distribute OpenSSL anymore. I was able to install cryptography using Homebrew and static build:

env CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1 LDFLAGS="$(brew --prefix openssl)/lib/libssl.a $(brew --prefix openssl)/lib/libcrypto.a" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography

More info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!