<commit_before>hapi-access-token
=================

Simple third party access token login plugin for Hapi
=======
### **hapi-access-token**

**hapi-access-token** is a third-party login plugin for [hapi](https://github.com/spumko/hapi). **hapi-access-token** comes with default support for Facebook. This was built with mobile apps in mind: mobile apps generally authenticate themselves with the installed app, and they simply receive an access token for future requests on the user's behalf. 

[![Build Status](https://secure.travis-ci.org/yoitsro/hapi-access-token.png)](http://travis-ci.org/yoitsro/hapi-access-token)

### Usage

Add a login endpoint and set it to use the **hapi-access-token** authentication strategy. 

**hapi-access-token** does not maintain a session. Once the handler is called, the application must set its own session management.

```javascript
var Hapi = require('hapi');
var Boom = require('boom');
var server = new Hapi.Server(8000);

// Register bell with the server
server.pack.register(require('hapi-access-token'), function (err) {

    // Declare an authentication strategy using the bell scheme
    // with the name of the provider, cookie encryption password,
    // and the OAuth client credentials.
    server.auth.strategy('hapi-access-token', 'hapi-access-token', {
        accessTokenKeyName: 'access_token', // The query parameter key you'll be specifying the access token in,
        profileUrl: 'https://graph.facebook.com/me?access_token=', // The url to get the user's profile,
        validateFunc: function(payload, accessToken, reply) { // The function which will extract the user profile and set it as the request's credentials
            try {
                var profile = JSON.parse(payload);<commit_msg>Fixed readme<commit_after>### **hapi-access-token**

**hapi-access-token** is a third-party login plugin for [hapi](https://github.com/spumko/hapi). **hapi-access-token** comes with default support for Facebook. This was built with mobile apps in mind: mobile apps generally authenticate themselves with the installed app, and they simply receive an access token for future requests on the user's behalf. 

[![Build Status](https://secure.travis-ci.org/yoitsro/hapi-access-token.png)](http://travis-ci.org/yoitsro/hapi-access-token)

### Usage

Add a login endpoint and set it to use the **hapi-access-token** authentication strategy. 

**hapi-access-token** does not maintain a session. Once the handler is called, the application must set its own session management.

```javascript
var Hapi = require('hapi');
var Boom = require('boom');
var server = new Hapi.Server(8000);

// Register bell with the server
server.pack.register(require('hapi-access-token'), function (err) {

    // Declare an authentication strategy using the bell scheme
    // with the name of the provider, cookie encryption password,
    // and the OAuth client credentials.
    server.auth.strategy('hapi-access-token', 'hapi-access-token', {
        accessTokenKeyName: 'access_token', // The query parameter key you'll be specifying the access token in,
        profileUrl: 'https://graph.facebook.com/me?access_token=', // The url to get the user's profile,
        validateFunc: function(payload, accessToken, reply) { // The function which will extract the user profile and set it as the request's credentials
            try {
                var profile = JSON.parse(payload);
{'fraction_non_alphanumeric': 0.11644236395552955, 'fraction_numerical': 0.0023405500292568754, 'mean_word_length': 3.9622641509433962, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6753140', 'n_tokens_mistral': 944, 'n_tokens_neox': 913, 'n_words': 351}