ananay / passport-apple

Passport strategy for Sign in with Apple
https://passport-apple.ananay.dev
142 stars 49 forks source link

Apple start loading but stop loading and does not do anything #29

Closed Goufix closed 2 years ago

Goufix commented 3 years ago

When I try to implement this using NestJS strategies. It just does not work properly. Anything about that?

ananay commented 3 years ago

Sorry, I can't understand the issue from the given info. Could you please record a video or take a pic to help me understand this better? Thanks!

NicoSerranoP commented 3 years ago

I had a similar issue but the problem was the following:

In the callback route, if you have an unidentified error then it does not return any responde therefore your browser would keep loading infinitely. To see the error I sent it as a response:

app.post("/auth", function(req, res, next) {
    passport.authenticate('apple', function(err, user, info) {
        if (err) {
            if (err == "AuthorizationError") {
                res.send("Oops! Looks like you didn't allow the app to proceed. Please sign in again! <br /> \
                <a href=\"/login\">Sign in with Apple</a>");
            } else if (err == "TokenError") {
                res.send("Oops! Couldn't get a valid token from Apple's servers! <br /> \
                <a href=\"/login\">Sign in with Apple</a>");
            }
        // NICO Edit's: 
        res.send(err);
        } else {
            res.json(user);
        }
    })(req, res, next);
});