【问题标题】:How to use PassportJS with Google Calendar (extracting calendar events)如何将 PassportJS 与 Google 日历一起使用(提取日历事件)
【发布时间】:2020-09-08 20:55:14
【问题描述】:

我正在尝试使用 PassportJS(Google OAuth 策略)对用户进行身份验证,并在他们登录并授予权限后提取日历事件。

我看过 Google Calendar API Node.js 快速入门,但他们通过 OAuth2 客户端使用它。正在使用 PassportJS 做我想做的事吗?谢谢!

【问题讨论】:

    标签: node.js oauth-2.0 passport.js google-calendar-api


    【解决方案1】:

    是的,Passport 绝对可以做到这一点。您需要为 Passport 配置 Google 策略并包含日历 API 范围 https://www.googleapis.com/auth/calendar

    参考代码:https://github.com/jaredhanson/passport-google-oauth2

    然后您可以使用返回的访问令牌向日历 API 发出请求。

    活动资源:https://developers.google.com/calendar/v3/reference/events/list

    【讨论】:

    • 嗨,杰森,感谢您的回复!嗯,是的,我正在使用 google-oauth-20 策略,并且在我的范围内也包含了“googleapis.com/auth/calendar.readonly”。但是,我的问题是,在将用户发送到我有 passport.authenticate("google") 的 callbackURL 后,我不确定如何使用 passport.use 中的完成(回调)函数将客户端发送到另一个页面.将不胜感激一些建议!谢谢!
    猜你喜欢
    • 2018-06-16
    • 2012-01-06
    • 2015-02-14
    • 1970-01-01
    • 2011-11-06
    • 1970-01-01
    • 2022-08-05
    • 2011-08-03
    • 1970-01-01
    相关资源
    最近更新 更多