Giter VIP home page Giter VIP logo

Comments (7)

valvoline avatar valvoline commented on May 31, 2024

I found the issue. In oauth.js I added the following debug code:

// Obtain token
Wreck.post(settings.provider.token, requestOptions, function (err, res, payload) {
            console.log("ERR: ", err);
            console.log("payload: ", payload);
            console.log("res: ", res);

This give me a more in-deep analysis about my misconfiguration. Specifically, I found that the app was configured as a Desktop one. Changing the settings from Facebook developers app, Advanced Settings, solved the issue.

I also reverted the server configuration as follow:

server.register(Bell, function (err) {

   server.auth.strategy('facebook', 'bell', {
        provider: 'facebook',
        password: 'password',
        isSecure: false,
        // Make sure to set a "Callback URL" and
        // check the "Allow this application to be used to Sign in with Twitter"
        // on the "Settings" tab in your Twitter application
        clientId: '832516966762800',                                // Set client id
        clientSecret: '4256a8f3a381735507d0a2eb67770577'            // Set client secret
    });

    server.route({
        method: '*',
        path: '/bell/facebook',
        config: {
            auth: 'facebook',
            handler: function (request, reply) {
                reply('<pre>' + JSON.stringify(request.auth.credentials, null, 4) + '</pre>');
            }
        }
    });
});

now, It works like a charm.

from bell.

geek avatar geek commented on May 31, 2024

@valvoline glad it all worked out. Are you interested in adding a Facebook example to the /examples folder?

from bell.

valvoline avatar valvoline commented on May 31, 2024

Sure,

I have also just completed a provider for linkedin and it works like a charm. Are you interested?

regards,

c.

On 15 Dec 2014, at 18:32, Wyatt Preul [email protected] wrote:

@valvoline https://github.com/valvoline glad it all worked out. Are you interested in adding a Facebook example to the /examples folder?


Reply to this email directly or view it on GitHub #46 (comment).

from bell.

geek avatar geek commented on May 31, 2024

@valvoline absolutely interested, thanks!

from bell.

hzaheer avatar hzaheer commented on May 31, 2024

@valvoline can u provide the linkedin config?
thanks a ton!

from bell.

valvoline avatar valvoline commented on May 31, 2024

Absolutely yes!

I have no time at the moment to fork a branch, so I attach here our working config.

on your server.js (or whatever you maintain your route / auth strategy) add the following:

    server.auth.strategy('linkedin', 'bell', {
        provider            : 'linkedin',
        password            : 'password',
        isSecure            : false,
        clientId            : '#yourClientID#',                                 
        clientSecret        : '#yourClientSecret#'            
    });

    server.route({
        method: '*',
        path: '/bell/linkedin',
        config: {
            auth: 'linkedin',
            handler: function (request, reply) {
                console.log('credentials: ' + request.auth.credentials);
            }
        }
    });

Also, under bell/providers folder, create a linkedin.js file with the following content:

//
//  linkedin plugin bell/hapijs
//
//  Created by valvoline on 15/12/14.
//  Copyright (c) 2014 Costantino Pistagna. All rights reserved.
//
// Load modules

var Crypto = require('crypto');

// Declare internals

var internals = {};


exports = module.exports = function (options) {

    return {
    protocol: 'oauth2',
    auth: 'https://www.linkedin.com/uas/oauth2/authorization',
    token: 'https://www.linkedin.com/uas/oauth2/accessToken',
    scope: ['r_fullprofile', 'r_emailaddress', 'r_network', 'r_contactinfo', 'rw_groups'],
    scopeSeparator: ',',
    profile: function (credentials, params, get, callback) {
        var query = {
        format: 'json',
        appsecret_proof: Crypto.createHmac('sha256', this.clientSecret).update(credentials.token).digest('hex')
        };
        get('https://api.linkedin.com/v1/people/~:(id,first-name,last-name,industry,associations,interests,publications,patents,languages,skills,educations,three-current-positions,num-recommenders,following,suggestions)', query, function (profile) {

            credentials.profile = profile;
            return callback();
            });
    }
    };
};

Also, be sure to modify your bell/lib/providers/index.js file accordingly:

exports = module.exports = {
    linkedin: require('./linkedin'),
...

That's all! Happy OAuth2

from bell.

lock avatar lock commented on May 31, 2024

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

from bell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.