前提・実現したいこと
GoogleSpreadシートのセルを出力したい
ここに質問の内容を詳しく書いてください。
出力するシート:https://docs.google.com/spreadsheets/d/1Pq6pKfLRQ5sb1ffJSmmTKGpy3bheWiH0miy-1tDWPI8/edit#gid=0
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/google/oauth2/_client.py", line 156, in jwt_grant access_token = response_data["access_token"] KeyError: 'access_token' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/yoshitakanishikawa/Desktop/python/practice.py", line 13, in <module> worksheet = gs.open_by_key(SPREADSHEET_KEY).worksheet("発注管理表") File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/gspread/models.py", line 313, in worksheet sheet_data = self.fetch_sheet_metadata() File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/gspread/models.py", line 265, in fetch_sheet_metadata r = self.client.request('get', url, params=params) File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/gspread/client.py", line 61, in request response = getattr(self.session, method)( File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/requests/sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/google/auth/transport/requests.py", line 477, in request self.credentials.before_request(auth_request, method, url, request_headers) File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/google/auth/credentials.py", line 133, in before_request self.refresh(request) File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/google/oauth2/service_account.py", line 376, in refresh access_token, expiry, _ = _client.jwt_grant( File "/Users/yoshitakanishikawa/.pyenv/versions/3.8.2/lib/python3.8/site-packages/google/oauth2/_client.py", line 159, in jwt_grant six.raise_from(new_exc, caught_exc) File "<string>", line 3, in raise_from google.auth.exceptions.RefreshError: ('No access token in response.', {'id_token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImZkMjg1ZWQ0ZmViY2IxYWVhZmU3ODA0NjJiYzU2OWQyMzhjNTA2ZDkiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL2RvY3MuZ29vZ2xlLmNvbS9zcHJlYWRzaGVldHMvZmVlZHMsaHR0cHM6Ly93d3cuZ29vZ2xlYXBpcy5jb20vYXV0aC9kcml2ZSIsImF6cCI6InNoZWV0LXRlc3RAc29kaXVtLWJ1cm5lci0zMDQyMDkuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJlbWFpbCI6InNoZWV0LXRlc3RAc29kaXVtLWJ1cm5lci0zMDQyMDkuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZXhwIjoxNjEyNzgxNTg5LCJpYXQiOjE2MTI3Nzc5ODksImlzcyI6Imh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbSIsInN1YiI6IjExODA2MzMwMzcyNTg5NTM4MDczMiJ9.ipYJWGPROc4AFGnYrPOzFWKQGwoy5WUny4TXF6JCwL2dNdZK0Em33bg3kspuRQvYRBxOOErmNMJiCs8QGc64ZPnbc9ptsdlEdCRApE1i9dcVACOTsyXldNTvzBhTcK_itLtsavdHdan98LimQDRWvsxaM0pnVBfYNPpFZpF2GHLLgRBthpvkDvM-f6iW3VYrGvF3oUOpRSZdPxH7trDhN8Krm1mBzTXLSX2QHC6h4HZK_9pMuTTwYHnKP71GFR2vjvDCEkuaXJD1_kIbjyog9dGkCnRk1Iclu4ODlQfSmnBf6wseSeKIkORy3y8-n-eiA_Hnv6eqhygEAw5E1zR3Yw'})
該当のソースコード
python
1import gspread 2from oauth2client.service_account import ServiceAccountCredentials 3 4SCOPE = ["https://docs.google.com/spreadsheets/feeds","https://www.googleapis.com/auth/drive"] 5SERVICE_ACCOUNT_FILE = "sodium-burner-304209-0b84d26de23a.json" 6SERVICE_ACCOUNT_FILE2 = "/Users/yoshitakanishikawa/Desktop/python/sodium-burner-304209-0b84d26de23a.json" 7 8credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACCOUNT_FILE,SCOPE) 9 10gs = gspread.authorize(credentials) 11 12SPREADSHEET_KEY = "1Pq6pKfLRQ5sb1ffJSmmTKGpy3bheWiH0miy-1tDWPI8" 13worksheet = gs.open_by_key(SPREADSHEET_KEY).worksheet("発注管理表") 14 15print(worksheet.acell("D2").value)
補足情報(FW/ツールのバージョンなど)
Mac M1
VScode
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。