AppleSignInStrategy

AppleSignInStrategy

new AppleSignInStrategy(options, verify)

Strategy constructor.

This authentication strategy authenticates and authorizes requests by using the new "Sign in with Apple" service. It uses the OAuth 2.0 protocol.

Applications must supply a verify callback which accepts an accessToken, refreshToken and service-specific profile, and then calls the done callback supplying a user, which should be set to false if the credentials are not valid. If an exception occured, err should be set.

Options:

  • clientID your Apple client id
  • clientSecret your Apple client secret
  • callbackURL URL to which Apple will redirect the user after granting authorization
  • scope [Optional] An array of named scopes
Parameters:
Name Type Description
options Object

The options for the strategy.

Properties
Name Type Description
clientID string

Your Apple client id.

clientSecret string

Your Apple client secret.

callbackURL string

URL to which Apple will redirect the user after granting authorization.

scope Array.<string>

An array of named scopes

verify function

The function to verify the user against a database in.

Source:
Example
passport.use(new AppleSignInStrategy({
    clientID: 'app key',
    clientSecret: 'app secret'
        callbackURL: 'https://www.example.com/auth/apple-sign-in/callback'
    },
    function(accessToken, refreshToken, profile, done) {
        User.findOrCreate(..., function (err, user) {
            done(err, user);
        });
    }
));