Google Calendar API的令牌泡菜问题

问题描述

我正在尝试将Alexa的技能与Google Calendar API连接起来。我以Google quick start作为参考。

class CalendarIntentHandler(AbstractRequestHandler):
    def handle(self,handler_input):
        event = {
        'summary': 'Test','location': 'At home','description': 'A chance to hear more about Google\'s developer products.','start': {
            'dateTime': '2020-07-29T12:12:10','timeZone': 'America/Los_Angeles',},'end': {
            'dateTime': '2020-07-29T12:32:47',}
        }
        creds = None
        if os.path.exists('token.pickle'):
            with open('token.pickle','rb') as token:
                creds = pickle.load(token)
        # If there are no (valid) credentials available,let the user log in.
        if not creds or not creds.valid:
            if creds and creds.expired and creds.refresh_token:
                creds.refresh(Request())
            else:
                #Alexa way of retrieving user's access token
                creds = handler_input.request_envelope.context.system.user.access_token
            # Save the credentials for the next run
            with open('token.pickle','wb') as token:
                pickle.dump(creds,token)

但是,我得到了:

Traceback (most recent call last):
  File "/opt/python/lib/python3.8/site-packages/ask_sdk_runtime/dispatch.py",line 118,in dispatch
    output = self.__dispatch_request(handler_input)  # type: Union[Output,None]
  File "/opt/python/lib/python3.8/site-packages/ask_sdk_runtime/dispatch.py",line 182,in __dispatch_request
    output = supported_handler_adapter.execute(
  File "/opt/python/lib/python3.8/site-packages/ask_sdk_runtime/dispatch_components/request_components.py",line 437,in execute
    return handler.handle(handler_input)
  File "/var/task/lambda_function.py",line 280,in handle
    with open('token.pickle','wb') as token:
OSError: [Errno 30] Read-only file system: 'token.pickle'END RequestId

我尝试将wb更改为rb,但这也不起作用。非常感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)