Skip to content

Apple callback redirects back to apple #62

Description

@SchmellaKaa

Package: passport-apple

Applied fix: Param merge fails in Express v5 because req.query is now a getter #59

Apple redirect back to callback URL succeeds ("/auth/apple/callback"), however the verify function of the AppleStrategy is not executed.

  passport.use(
        new AppleStrategy(
            {
                clientID: "AAA",
                teamID: "BBB",
                keyID: "CCC",
                privateKeyString: process.env.APPLE_CLIENT_SECRET,
                callbackURL: "/auth/apple/callback",
                passReqToCallback: true,
            },
            async (req, accessToken, refreshToken, idToken, profile, cb) => {
                   ...
                   return cb(null, user)
            }
        )
app.get("/auth/apple", (req, res, next) => {
    passport.authenticate("apple", {session: false})(req, res, next);
});
app.post("/auth/apple/callback", (req, res, next) => {
    passport.authenticate("apple", (err: any, user: Express.User | false, info: any) => {
        ...
        redirect("/")
    }
)

Behaviour:

  • User click on the "Sign in with Apple" button
  • User gets redirected to apple to authenticate
  • Apple redirects back to "/auth/apple/callback" url (res.headers contains location pointing to https://appleid.apple.com/auth/authorize?state=c5bca4a976&response_type=code&scope=name%20email&response_mode=form_post&redirect_uri=https%3A%2F%2Fmy.domain.com%2Fauth%2Fapple%2Fcallback&client_id=AAA
  • My "auth/apple/callback function gets executed, but the passport.authenticate("apple", (err, user, info) => {...})) function located inside the post call does not get executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions