<commit_before># passport-trademe

[Trade Me](http://www.trademe.co.nz) authentication strategy for [Passport](http://passportjs.org/).

## Installation

### Installing passport-trademe
```
  [sudo] npm install passport-trademe
  
  // or for this updated FORK install like this:
  // where 1.0.0.1 = release number. Look for the latest release from above
  npm install https://github.com/tealdit/passport-trademe/archive/1.0.0.1.tar.gz --save
  
```

## Motivation
Fame, fortune ... free beer.  

## Usage

Very simple ...

``` js
	var passport = require( 'passport' )		
		, TrademeStrategy = require( 'passport-trademe' ).Strategy
		
	...
	
	var trademeKey = require( './keys/trademeKey' );
	passport.use(new TrademeStrategy( {
		consumerKey: trademeKey.consumerKey
		, consumerSecret: trademeKey.consumerSecret
		, callbackURL: app.get( 'site-url' ) + '/auth/trademe/callback'
	}
	, function( token, tokenSecret, profile, done ) {
	
		...
		
		}
	) );
	
	...
	
	app.configure( function() {
		app.use( passport.initialize() );
		app.use( passport.session() );
		app.use( app.router );
	} );
```

Define you "conversation" routes ...

```js
	app.get( '/auth/trademe'
		, passport.authenticate( 'trademe'
			, { 
				// Add the scope of your application here
				scope: [ 'MyTradeMeRead'
					, 'MyTradeMeWrite'
					, 'BiddingAndBuying' ] <commit_msg>Include trademeConfig.js content<commit_after># passport-trademe

[Trade Me](http://www.trademe.co.nz) authentication strategy for [Passport](http://passportjs.org/).

## Installation

### Installing passport-trademe
```
  [sudo] npm install passport-trademe
  
  // or for this updated FORK install like this:
  // where 1.0.0.1 = release number. Look for the latest release from above
  npm install https://github.com/tealdit/passport-trademe/archive/1.0.0.1.tar.gz --save
  
```

## Motivation
Fame, fortune ... free beer.  

## Usage

Very simple ...

``` js
	var passport = require( 'passport' )		
		, TrademeStrategy = require( 'passport-trademe' ).Strategy
		
	...
	
	var trademeConfig = require( './keys/trademeConfig' );
	passport.use(new TrademeStrategy( {
		consumerKey: trademeConfig.consumerKey
		, consumerSecret: trademeConfig.consumerSecret
		, callbackURL: app.get( 'site-url' ) + '/auth/trademe/callback'
	}
	, function( token, tokenSecret, profile, done ) {
	
		...
		
		}
	) );
	
	...
	
	app.configure( function() {
		app.use( passport.initialize() );
		app.use( passport.session() );
		app.use( app.router );
	} );
```

### Content of ./keys/trademeConfig.js
```js
/**
 * Expose constructors.
 */
var apiBaseUrl      = 'https://api.trademe.co.nz/v1/';
var oAuthBaseUrl    = 'https://secure.trademe.co.nz/Oauth/';

var env = 'staging';
switch (env){
    case 'staging':
        apiBaseUrl      = 'https://api.tmsandbox.co.nz/v1/';
        oAuthBaseUrl    = 'https://secure.tmsandbox.co.nz/Oauth/';
        break;
    default:
}
module.exports = {
    consumerKey     : '<KEY>',
    consumerSecret  : 'F33456645479B111B44386EC085A7C',
    apiBaseUrl      : apiBaseUrl,
    oAuthBaseUrl    : oAuthBaseUrl,
    callbackURL     : 'http://127.0.0.1:3000/auth/trademe/callback'
};
```

Define you "conversation" routes ...

```js
	app.get( '/auth/trademe'
		, passport.authenticate( 'trademe'
			, { 
				// Add the scope of your application here
				scope: [ 'MyTradeMeRead'
					, 'MyTradeMeWrite'
					, 'BiddingAndBuying' ] 
{'fraction_non_alphanumeric': 0.15792575132586917, 'fraction_numerical': 0.015026517383618149, 'mean_word_length': 3.022511848341232, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '35156', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1196, 'n_words': 242}