## Installation

    $ npm install passport-typcn-account

## Usage

#### Configure Strategy

The typcn authentication strategy authenticates users using a typcn account
and OAuth 2.0 tokens.  The strategy requires a `verify` callback, which accepts
these credentials and calls `done` providing a user, as well as `options`
specifying a client ID, client secret, and callback URL.

    passport.use(new TYPStrategy({
        clientID: client_id,
        clientSecret: client_secret
      },
      function(accessToken, refreshToken, profile, done) {
        User.findOrCreate({ typId: profile.id }, function (err, user) {
          return done(err, user);
        });
      }
    ));

#### Authenticate Requests

Use `passport.authenticate()`, specifying the `'typaccount'` strategy, to
authenticate requests.

For example, as route middleware in an [Express](http://expressjs.com/)
application:

    app.get('/auth/typaccount',
      passport.authenticate('typaccount'),
      function(req, res){
        // The request will be redirected to typaccount for authentication, so this
        // function will not be called.
      });

    app.get('/auth/typaccount/callback', 
      passport.authenticate('typaccount', { failureRedirect: '/login' }),
      function(req, res) {
        // Successful authentication, redirect home.
        res.redirect('/');
      });