2017-03-07 14 views
0

私はGoogle APIで新しく、Python経由でGoogle Content APIに接続しようとしています。私はそのためにサービスアカウントを使用しています。Python経由でGoogle Content APIに接続

私のスクリプトは非常に簡単でわかりやすいです:承認プロセスで

from apiclient.discovery import build 
from oauth2client.service_account import ServiceAccountCredentials 

import httplib2 

credentials = ServiceAccountCredentials.from_p12_keyfile(
    'xxxxx.iam.gserviceaccount.com', 
    '/Users/Downloads/pkey.txt', 
    scopes='https://www.googleapis.com/auth/content') 


http = credentials.authorize(httplib2.Http()) 

service = build('https://www.googleapis.com/content', 'v2') 

私はこのエラーを取得する:

Traceback (most recent call last): 
    File "/Users/PycharmProjects/authorization.py", line 22, in <module> 
    service = build('https://www.googleapis.com/content', 'v2') 
    File "build/bdist.macosx-10.11-intel/egg/oauth2client/_helpers.py", line 133, in positional_wrapper 
    File "build/bdist.macosx-10.11-intel/egg/googleapiclient/discovery.py", line 228, in build 
    File "build/bdist.macosx-10.11-intel/egg/googleapiclient/discovery.py", line 275, in _retrieve_discovery_doc 
    File "/Library/Python/2.7/site-packages/httplib2-0.10.3-py2.7.egg/httplib2/__init__.py", line 1659, in request 
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) 
    File "/Library/Python/2.7/site-packages/httplib2-0.10.3-py2.7.egg/httplib2/__init__.py", line 1399, in _request 
    (response, content) = self._conn_request(conn, request_uri, method, body, headers) 
    File "/Library/Python/2.7/site-packages/httplib2-0.10.3-py2.7.egg/httplib2/__init__.py", line 1319, in _conn_request 
    conn.connect() 
    File "/Library/Python/2.7/site-packages/httplib2-0.10.3-py2.7.egg/httplib2/__init__.py", line 1069, in connect 
    self.ssl_version, self.host) 
    File "/Library/Python/2.7/site-packages/httplib2-0.10.3-py2.7.egg/httplib2/__init__.py", line 97, in _ssl_wrap_socket 
    return context.wrap_socket(sock, server_hostname=hostname) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 352, in wrap_socket 
    _context=self) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 579, in __init__ 
    self.do_handshake() 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 816, in do_handshake 
    match_hostname(self.getpeercert(), self.server_hostname) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 271, in match_hostname 
    % (hostname, ', '.join(map(repr, dnsnames)))) 
ssl.CertificateError: hostname 'https%3a%2f%2fwww.googleapis.com%2fcontent.googleapis.com' doesn't match either of '*.googleapis.com', '*.clients6.google.com', '*.cloudendpointsapis.com', 'cloudendpointsapis.com', 'googleapis.com' 

Process finished with exit code 1 

それは私の権限で行う必要がありますか?または私は何か間違っている? ご協力いただきありがとうございます!

答えて

関連する問題