Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Building a customised dash component - Authentication via Facebook

$
0
0

@monitorcasalab wrote:

So I am trying to create a custom component for authenticate an user from existing Facebook account. I have been following the dash-component-boilerplate.
The process of the initial setup of the package is comprehensive, however I am crashing in tweaking the JS code to a dash friendly

The react js code is: available at https://www.npmjs.com/package/react-facebook-login
The appId number is generated by Facebook for developers website and it should be part of the input of the component, I called this below as “###############”

**The sample JS code to adopt is:**

import React from 'react';
import ReactDOM from 'react-dom';
import FacebookLogin from 'react-facebook-login';

const responseFacebook = (response) => {
console.log(response);
}
ReactDOM.render(
<FacebookLogin
    appId="###############"
    autoLoad={true}
    fields="name,email,picture"
    onClick={componentClicked}
    callback={responseFacebook} />,
document.getElementById('demo')

);

issue

The boilerplate methodology works with no issues, generating the dash package and runs, I get the pop up window and I include username and details, However I cannot extract the name and email in an output variable which is the main intent of this task.

Here the tweaked js code:

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import FacebookLogin from 'react-facebook-login';
const responseFacebook = (response) => {
  console.log(response);
}
export default class facebookauth extends React.Component {
    render() {
        const {id, label, appId, autoLoad,  n_clicks} = this.props;
        return (
            <div id={id}>
                testing the facebook auth: {label}&nbsp;
                <FacebookLogin
                  appId="###############"
                  autoLoad={false}
                  fields="name, picture, email"
                  callback={responseFacebook}
                  cssClass="my-facebook-button-class"
                  icon="fa-facebook"
                />,
                <div>State</div>
                    'name = '{responseFacebook}
                </div>
        );
    }
}
facebookauth.defaultProps = {};
facebookauth.propTypes = {
    id: PropTypes.string,
    label: PropTypes.string.isRequired,
    appId: PropTypes.string,
    fields: PropTypes.string,
    setProps: PropTypes.func,
    n_clicks: PropTypes.oneOf(['change'])
};

Question
Is there anyone in the community who can give some advice?, the logic around react code is way different than python.

Cheers!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles