Google Calendar API v3 - How to obtain a refresh token (Python)

后端 未结 4 772
离开以前
离开以前 2020-12-29 06:51

I am trying to write a Django app which creates events in a specific Google calendar. So far I have been successful. There is only a little problem:

I don\'t

4条回答
  •  生来不讨喜
    2020-12-29 07:20

    So if you've already accepted consent without setting access_type='offline', you need to force the user to consent to your app with offline access by also passing approval_prompt='force'.

    self.flow = OAuth2WebServerFlow(
        client_id=self.client_id,
        client_secret=self.client_secret,
        scope=self.SCOPE,
        user_agent=user_agent,
        redirect_uri='urn:ietf:wg:oauth:2.0:oob',
        access_type='offline', # This is the default
        approval_prompt='force'
    )
    

    Then you can remove the force prompt/set it to auto after you get the refresh token.

提交回复
热议问题