2

Googleカレンダーのapiプロジェクトのサービスアカウントを設定しました。アイデアは、それが実際に起こったので、私はOAuth 2.0 client IDを接続したGoogleHttpAccessTokenRefreshError at ... unauthorized_client:クライアントはこのメソッドを使用してアクセストークンを取得する権限がありません

Service account clients are created when domain-wide delegation is 
enabled on a service account. 

で入れたので、私のウェブサイトは、など私のGoogleカレンダーと表示イベントに接続できることです。ここまでは順調ですね。私は、私が接続し、このコード

from cal.models import Cal as Caldb 
import httplib2 

from apiclient.discovery import build 
from oauth2client.file import Storage 
from oauth2client.client import OAuth2WebServerFlow 
from oauth2client import tools 

from calendar import monthrange 
from calendar_gui import MyCalendar 
from datetime import datetime 
from datetime import date 
from django.utils.safestring import mark_safe 

from oauth2client.service_account import ServiceAccountCredentials 
import os 
from django.conf import settings 

def authenticate(): 
    scope= ['https://www.googleapis.com/auth/calendar'] 
    credentials = ServiceAccountCredentials.from_json_keyfile_name(os.path.join(settings.PROJECT_ROOT, '../', 'myjson.json'), scopes=scope) 
    delegated_credentials = credentials.create_delegated('[email protected]') 

    http = httplib2.Http() 
    http = delegated_credentials.authorize(http) 
    service = build(serviceName='calendar', version='v3', http=http, credentials=credentials) 

    return service 

しかし、私はGoogleカレンダーAPIを有効にしている

service = build(serviceName='calendar', version='v3', http=http, credentials=credentials) 
File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 137, in positional_wrapper 
return wrapped(*args, **kwargs) 
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/discovery.py", line 214, in build 
cache) 
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/discovery.py", line 261, in _retrieve_discovery_doc 
resp, content = http.request(actual_url) 
File "/usr/local/lib/python2.7/dist-packages/oauth2client/transport.py", line 153, in new_request 
credentials._refresh(orig_request_method) 
File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 765, in _refresh 
self._do_refresh_request(http_request) 
File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 834, in _do_refresh_request 
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status) 
HttpAccessTokenRefreshError: unauthorized_client: Client is unauthorized to retrieve access tokens using this method.  

悲しいかなを使用して認証しようとするために使用さjsonファイルを生成しました。実際、私はすべてのステップに従ったような気がします。実際、私はこれまで一度も成功しましたが、今は困惑しています。私はこのすべてが効力を発する前に24-48時間待つ必要があるかもしれないと読んでいます。それはそれほど単純ではありませんか?

今のところ、私はこれをローカルでテストしています。まだサーバーに何もプッシュしていません。

答えて

0

チェックこのリンクをチェックアウト: Google API Python unauthorized_client: Unauthorized client or scope in request

あなたのAPIの範囲を設定するときに「管理APIクライアントアクセス」でクライアント名として自分の「デベロッパーコンソール」から、クライアントのIDを使用する必要があります。

+0

私はそれを見ましたが、私はクライアント鍵と共に私のために自動的に生成された 'json'ファイルに接続しようとしています。 –

関連する問題