Last active
August 29, 2015 14:25
-
-
Save kndt84/f8050638fdfe73c4459d to your computer and use it in GitHub Desktop.
PythonからGoogle APIsを利用する際のOAuth2エラーの対処方法 ref: http://qiita.com/kndt84/items/4c2b16000b0ce32b6bcf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssl.SSLError: [Errno 185090050] _ssl.c:343: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> sudo chmod 644 cacerts.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment