kidtronnix / hapi-dash

Boilerplate Hapi Web and API Server Example, with frontend dashboard.
hapi-dash.smaxwellstewart.com
MIT License
113 stars 19 forks source link

authentication is not working #6

Closed pandeysoni closed 10 years ago

pandeysoni commented 10 years ago

auth:"core" is not working.. when i used auth:"core", it is giving error unauthorised

kidtronnix commented 10 years ago

Did you use the core credentials in config.js?

On 10 September 2014 07:12, pandeysoni notifications@github.com wrote:

auth:"core" is not working.. when i used auth:"core", it is giving error unauthorised

— Reply to this email directly or view it on GitHub https://github.com/smaxwellstewart/hapi-dash/issues/6.

pandeysoni commented 10 years ago

yupp i use this.. how can i find the path of register page? the problem i am facing is that when i am using the path "app/user" and post this data than i am getting error unauthoried, and message "missing authetication".

kidtronnix commented 10 years ago

Ok I will look into this.

Simon

On 10 September 2014 11:00, pandeysoni notifications@github.com wrote:

yupp i use this.. how can i find the path of register page? the problem i am facing is that when i am using the path "app/user" and post this data than i am getting error unauthoried, and message "missing authetication".

— Reply to this email directly or view it on GitHub https://github.com/smaxwellstewart/hapi-dash/issues/6#issuecomment-55094715 .

pandeysoni commented 10 years ago

ok simon, this application is very helpful but i m in stuck for authentciation.how is it working?

kidtronnix commented 10 years ago

Here is an example of a Hawk authenticated request:

var Request = require('request');
var Hawk = require('hawk');

// Client credentials, find them in config.js, in the `coreCreds` field
var credentials = {
    id: 'core',
    key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
    algorithm: 'sha256'
}

// Request options

var requestOptions = {
    uri: 'http://localhost:3000/api/user',
    method: 'GET',
    headers: {}
};

// Generate Authorization request header

var header = Hawk.client.header('http://localhost:3000/api/user', 'GET', { credentials: credentials, ext: 'some-app-data' });
requestOptions.headers.Authorization = header.field;

// Send authenticated request

Request(requestOptions, function (error, response, body) {

    // Output results
    console.log(body);
});