2016-03-30 14 views
1

私はGoogleスプレッドシートにアクセスする権限を与えられたPythonスクリプトを持っていました。Oauth2でGoogle APIを認証できません

oauth2client.client.AccessTokenRefreshError: invalid_client: The OAuth client was not found. 

私の認証コードは次のようになります:今、私はそれを実行すると、それが例外をスローした場合でも、

import json 
import gspread 
from oauth2client.client import SignedJwtAssertionCredentials 

json_key = json.load(open('myapp-credentials.json')) 
scope = ['https://spreadsheets.google.com/feeds'] 
credentials = SignedJwtAssertionCredentials(
    json_key['client_email'], 
    json_key['private_key'], scope) 
gc = gspread.authorize(credentials) 

私は、アカウントには何も変わっていませんでしたので、私は理由を知りませんそれは突然働きを止めるでしょう。 https://console.developers.google.com/apis/credentialsにログインしても、アプリがまだ登録されています。これを診断してアクセス権を再度有効にするにはどうすればよいですか?このエラーを検出すると、残念なことに何十もの潜在的な原因が見つかります。

答えて

0

クラスSignedJwtAssertionCredentialsは、2016年2月5日現在removed from the source codeであり、その機能はServiceAccountCredentialsのものに置き換えられました。これにより、エラーが発生する可能性があります。

あなたのcredentialsを生成するには、次のようなものを使用したいと思うことが表示されます:

credentials = ServiceAccountCredentials.from_json_keyfile_name('myapp-credentials.json', scope) 

このGithub issue threadが同様に、役に立つかもしれませんが。

関連する問題