<commit_before># Using Auth0 in Node.js APIs

@@includes.apinote@@

Installing the following package will provide an Express middleware that validates a [JSON Web Token](jwt).

	 npm install express-jwt

Add the following to your express application:

  	var jwt = require('express-jwt');

  	var authenticate = jwt({
  	  secret: new Buffer('@@account.clientSecret@@', 'base64'),
  	  audience: '@@account.clientId@@'
  	});

  	app.configure(function() {
  	  ...
  	  // intercept all /api calls and validate the token
  	  app.use('/api', authenticate);
  	  ...
  	});

> If you are not using Express you can use the [jsonwebtoken package](https://github.com/auth0/node-jsonwebtoken) which provides the underlying token validation functionality used by `express-jwt`.

@@includes.callapi@@<commit_msg>Update nodeapi-tutorial.md<commit_after># Using Auth0 in Node.js APIs

@@includes.apinote@@

Installing the following package will provide an Express middleware that validates a [JSON Web Token](jwt).

	 npm install express-jwt

Add the following to your express application:

  	var jwt = require('express-jwt');

  	var authenticate = jwt({
  	  secret: new Buffer('@@account.clientSecret@@', 'base64'),
  	  audience: '@@account.clientId@@'
  	});

  	app.configure(function() {
  	  ...
  	  // intercept all /api calls and validate the token
  	  app.use('/api', authenticate);
  	  ...
  	});

Finally, get the user information by doing:

	app.get('/api/hello', function(req, res) {
	  res.send('Hello ' + req.user.name);
	});

> If you are not using Express you can use the [jsonwebtoken package](https://github.com/auth0/node-jsonwebtoken) which provides the underlying token validation functionality used by `express-jwt`.

@@includes.callapi@@
{'fraction_non_alphanumeric': 0.1267765776009096, 'fraction_numerical': 0.0045480386583285955, 'mean_word_length': 3.7184986595174263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6301445', 'n_tokens_mistral': 560, 'n_tokens_neox': 535, 'n_words': 168}