Class: module.exports(provider, authScheme, externalId, profile, credentials, userId, created, modified)

Tracks third-party logins and profiles.

Arguments
Name Type Description
provider String

Auth provider name, such as facebook, google, twitter, linkedin.

authScheme String

Auth scheme, such as oAuth, oAuth 2.0, OpenID, OpenID Connect.

externalId String

Provider specific user ID.

profile Object

User profile, see http://passportjs.org/guide/profile.

credentials Object

Credentials. Actual properties depend on the auth scheme being used:

  • oAuth: token, tokenSecret
  • oAuth 2.0: accessToken, refreshToken
  • OpenID: openId
  • OpenID: Connect: accessToken, refreshToken, profile
userId

The LoopBack user ID.

created Date

The created date

modified Date

The last modified date

Class: module.exports Static Methods

UserIdentity.login(provider, authScheme, profile, credentials, [options], cb)

Log in with a third-party provider such as Facebook or Google.

Arguments
Name Type Description
provider String

The provider name.

authScheme String

The authentication scheme.

profile Object

The profile.

credentials Object

The credentials.

[options] Object

The options.

cb Function

The callback function.

Callback
Name Type Description
err Error or String

The error object or string.

user Object

The user object.

[info] Object

The auth info object.

  • identity: UserIdentity object
  • accessToken: AccessToken object

Class: module.exports(provider, authScheme, externalId, profile, credentials, userId, created, modified)

Tracks third-party logins and profiles.

Arguments
Name Type Description
provider String

Auth provider name, such as facebook, google, twitter, linkedin.

authScheme String

Auth scheme, such as oAuth, oAuth 2.0, OpenID, OpenID Connect.

externalId String

Provider specific user ID.

profile Object

User profile, see http://passportjs.org/guide/profile.

credentials Object

Credentials. Actual properties depend on the auth scheme being used:

  • oAuth: token, tokenSecret
  • oAuth 2.0: accessToken, refreshToken
  • OpenID: openId
  • OpenID: Connect: accessToken, refreshToken, profile
userId

The LoopBack user ID.

created Date

The created date

modified Date

The last modified date

Class: module.exports Static Methods

UserCredential.link(provider, authScheme, profile, credentials, [options], cb)

Link a third party account to a LoopBack user

Arguments
Name Type Description
provider String

The provider name

authScheme String

The authentication scheme

profile Object

The profile

credentials Object

The credentials

[options] Object

The options

cb Function

The callback function

Callback
Name Type Description
err Error or String

The error object or string

[credential] Object

The user credential object

Class: module.exports()

Credentials associated with the LoopBack client application, such as oAuth 2.0 client ID/secret, or SSL keys

Class: module.exports Static Methods

ApplicationCredential.link(appId, provider, authScheme, credentials, cb)

Link a third-party application credential with the LoopBack application.

Arguments
Name Type Description
appId String

The LoopBack application iID.

provider String

The third party provider name.

authScheme String

The authentication scheme.

credentials Object

Credentials for the given scheme.

cb Function

The callback function.

Callback
Name Type Description
err Error or String

The error object or string.

user Object

The user object.

[info] Object

The auth info object.

  • identity: UserIdentity object
  • accessToken: AccessToken object

Class: PassportConfigurator(app)

The passport configurator

Arguments
Name Type Description
app Object

The LoopBack app instance

Returns
Name Type Description
result PassportConfigurator

Class: PassportConfigurator Static Methods

if()

Redirect the user to Facebook for authentication. When complete, Facebook will redirect the user back to the application at /auth/facebook/callback with the authorization code

if()

Facebook will redirect the user to this URL after approval. Finish the authentication process by attempting to obtain an access token using the authorization code. If access was granted, the user will be logged in. Otherwise, authentication has failed.

Class: PassportConfigurator Instance Methods

passportConfigurator.configureProvider(name, General Options, oAuth2 Options, Local Strategy Options, oAuth1 Options, OpenID Options)

Configure a Passport strategy provider.

Arguments
Name Type Description
name String

The provider name

General Options Object

Options for the auth provider. There are general options that apply to all providers, and provider-specific options, as described below.

oAuth2 Options Object

Options for oAuth 2.0.

Local Strategy Options Object

Options for local strategy.

oAuth1 Options Object

Options for oAuth 1.0.

OpenID Options Object

Options for OpenID.

General Options
Name Type Description
link Boolean

Set to true if the provider is for third-party account linking.

module Object

The passport strategy module from require.

authScheme String

The authentication scheme, such as 'local', 'oAuth 2.0'.

[session] Boolean

Set to true if session is required. Valid for any auth scheme.

[authPath] String

Authentication route.

oAuth2 Options
Name Type Description
[clientID] String

oAuth 2.0 client ID.

[clientSecret] String

oAuth 2.0 client secret.

[callbackURL] String

oAuth 2.0 callback URL.

[callbackPath] String

oAuth 2.0 callback route.

[scope] String

oAuth 2.0 scopes.

[successRedirect] String

The redirect route if login succeeds. For both oAuth 1 and 2.

[failureRedirect] String

The redirect route if login fails. For both oAuth 1 and 2.

Local Strategy Options
Name Type Description
[usernameField] String

The field name for username on the form for local strategy.

[passwordField] String

The field name for password on the form for local strategy.

oAuth1 Options
Name Type Description
[consumerKey] String

oAuth 1 consumer key.

[consumerSecret] String

oAuth 1 consumer secret.

[successRedirect] String

The redirect route if login succeeds. For both oAuth 1 and 2.

[failureRedirect] String

The redirect route if login fails. For both oAuth 1 and 2.

OpenID Options
Name Type Description
[returnURL] String

OpenID return URL.

[realm] String

OpenID realm.

passportConfigurator.init(noSession)

Initialize the passport configurator

Arguments
Name Type Description
noSession Boolean

Set to true if no session is required

Returns
Name Type Description
result Passport

passportConfigurator.setupModels(options)

Set up data models for user identity/credential and application credential

Arguments
Name Type Description
options Object

Options for models

options
Name Type Description
[userModel] Model

The user model class

[userCredentialModel] Model

The user credential model class

[userIdentityModel] Model

The user identity model class