最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google OAuth not requesting calendar.events scope in Node.js with Passport.js - Stack Overflow

programmeradmin0浏览0评论

I’m using Passport.js with Google OAuth 2.0 in my Node.js app to authenticate users and request access to Google Calendar events. Despite adding the calendar.events scope in both my Passport strategy and Google Cloud Console, the consent screen does not prompt for calendar access, and the returned access token is missing the calendar.events scope.

What I’ve tried:

Added calendar.events in the Passport strategy:

`passport.use(
  new GoogleStrategy(
    {
      clientID: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
      callbackURL: process.env.BACKEND_HOST + "/auth/google/callback",
      scope: [
        "email",
        ".events"
      ],
      accessType: "offline",
      prompt: "consent",
    },
    async (accessToken, refreshToken, profile, done) => {
      console.log("access token", accessToken);
      const response = await fetch(
        "=" +
          accessToken
      );
      const data = await response.json();
      console.log("Token Info:", data);
    }
  )
);`
  1. Verified that calendar.events is added in the Google Cloud Console under OAuth consent screen.

  2. Tested with to inspect the access token — only the default userinfo.email, userinfo.profile, and openid scopes are present.

  3. Added prompt: "consent" and accessType: "offline" to force re-consent.

  4. Revoked access via Google Permissions and retried, but still no prompt for calendar access.

Expected behavior:

The Google consent screen should prompt for calendar access when logging in. The access token should include the calendar.events scope. Actual behavior:

No calendar permission prompt is shown, and the token is missing the calendar.events scope. What could be causing this?

Is there any additional configuration required to request calendar.events? Could it be related to how Passport.js handles the scope?

发布评论

评论列表(0)

  1. 暂无评论