Skip to content

Instantly share code, notes, and snippets.

@kndt84
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kndt84/f8050638fdfe73c4459d to your computer and use it in GitHub Desktop.
Save kndt84/f8050638fdfe73c4459d to your computer and use it in GitHub Desktop.
PythonからGoogle APIsを利用する際のOAuth2エラーの対処方法 ref: http://qiita.com/kndt84/items/4c2b16000b0ce32b6bcf
import json
from httplib2 import Http
from oauth2client.client import SignedJwtAssertionCredentials
from apiclient.discovery import build
SERVICE_ACCOUNT_EMAIL = '**********@developer.gserviceaccount.com'
PROJECT_NUMBER = '**********'
KEYFILE='******************.p12'
with open(KEYFILE) as f:
private_key = f.read()
credentials = SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL, private_key,
'https://www.googleapis.com/auth/bigquery')
http = Http()
credentials.authorize(http)
service = build('bigquery', 'v2', http=http)
response = service.datasets().list(projectId='************').execute()
print response
ssl.SSLError: [Errno 185090050] _ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib
> cd /Library/Python/2.7/site-packages/httplib2-0.9.1-py2.7.egg/httplib2/
> ls -l cacerts.txt
-rw-r----- 1 root wheel 134862 7 13 18:36 cacerts.txt
> sudo chmod 644 cacerts.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment