2017-04-05 20 views
1

Googleカレンダーの予定を作成しようとしていますが、「client_secret.json」のFileNotFoundErrorが表示されています。ここでGoogle Calendar API FileNotFoundError:

from __future__ import print_function 
from apiclient.discovery import build 
from httplib2 import Http 
from oauth2client import file, client, tools 

try: 
    import argparse 
    flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() 
except ImportError: 
    flags = None 

SCOPES = 'https://www.googleapis.com/auth/calendar' 
store = file.Storage('storage.json') 
creds = store.get() 
if not creds or creds.invalid: 
    flow = client.flow_from_clientsecrets('client_secret.json', SCOPES) 
    creds = tools.run_flow(flow, store, flags) \ 
      if flags else tools.run(flow, store) 
CAL = build('calendar', 'v3', http=creds.authorize(Http())) 

GMT_OFF = '-07:00'  # PDT/MST/GMT-7 
EVENT = { 
    'summary': 'Dinner with friends', 
    'start': {'dateTime': '2015-09-15T19:00:00%s' % GMT_OFF}, 
    'end': {'dateTime': '2015-09-15T22:00:00%s' % GMT_OFF}, 
    'attendees': [ 
     {'email': '[email protected]'}, 
     {'email': '[email protected]'}, 
    ], 
} 

e = CAL.events().insert(calendarId='primary', 
     sendNotifications=True, body=EVENT).execute() 

print('''*** %r event added: 
    Start: %s 
    End: %s''' % (e['summary'].encode('utf-8'), 
     e['start']['dateTime'], e['end']['dateTime'])) 

はエラーです:

Warning (from warnings module): File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\oauth2client_helpers.py", line 255 warnings.warn(_MISSING_FILE_MESSAGE.format(filename)) UserWarning: Cannot access storage.json: No such file or directory Traceback (most recent call last): File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\oauth2client\clientsecrets.py", line 121, in _loadfile with open(filename, 'r') as fp: FileNotFoundError: [Errno 2] No such file or directory: 'client_secret.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/bakat/AppData/Local/Programs/Python/Python35-32/Diet Buddy/Google_Calendar.py", line 16, in flow = client.flow_from_clientsecrets('client_secret.json', SCOPES) File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\oauth2client_helpers.py", line 133, in positional_wrapper return wrapped(*args, **kwargs) File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\oauth2client\client.py", line 2125, in flow_from_clientsecrets cache=cache) File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\oauth2client\clientsecrets.py", line 165, in loadfile return _loadfile(filename) File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\oauth2client\clientsecrets.py", line 125, in _loadfile exc.strerror, exc.errno) oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secret.json', 'No such file or directory', 2)

答えて