Giter VIP home page Giter VIP logo

react-auth-client's Introduction

React Social Authentication Client

React Social Auth

Medium posts that detail this repo

Getting Started

git clone https://github.com/funador/react-auth-client.git
cd react-auth-client
npm i && HTTPS=true npm start

Because of Facebook, https is required. Even in development.

Facebook requires all apps interacting with their api (including those in development) to be served over https. This means you will need to run create-react-app in https mode. Plus set up certificates for your server. Go ahead and get yourself a cup of coffee. This could take a minute.

OS X

To add https to localhost follow these instructions.

You will also need to manually add the https certificate to Chrome as described here.

You may also need to open a seperate tab for https://localhost:8080 and accept the security warning before the client will push requests through.

Windows

Thanks to Le Gui PPF for providing the following instructions for setting up SSL locally on Windows:

"Hi thanks for the code ! I haven’t tried it yet cause I spent a whole day (hot minute huh !) figuring out how to generate proper ssl certificate with all Chrome requirements… for those who don’t want to lose their time => https://serverfault.com/a/850961 and add:

echo authorityKeyIdentifier=keyid,issuer
echo basicConstraints=CA:FALSE
echo keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment

to v3 req.

Hope that works for you Windows folks!

If you only want to use Twitter/Google/Github authentication (https is not required), follow the instructions in this branch

Client

Depending on your OS you will have to flag the HTTPS enviornment variable differently. Documentation for different operating systems is here.

Server

Follow the instructions in the server repo

Finally open https://localhost:3000

Deploy

Everything is set up to deploy to Netlify. You just need to npm run build on the client and deploy to netlify.

Issues

Something not working? Please open an issue

react-auth-client's People

Contributors

dependabot[bot] avatar funador avatar zianke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-auth-client's Issues

net::ERR_CERT_AUTHORITY_INVALID

i make a react client to authentication with Openid / Facebook but have a error with HTTPS self ssl certificate . How can i fix it ? Thankyou

./node_modules/engine.io-client/lib/transports/polling-xhr.js.Request.create @ polling-xhr.js:265
Request @ polling-xhr.js:167
./node_modules/engine.io-client/lib/transports/polling-xhr.js.XHR.request @ polling-xhr.js:94
./node_modules/engine.io-client/lib/transports/polling-xhr.js.XHR.doPoll @ polling-xhr.js:124
./node_modules/engine.io-client/lib/transports/polling.js.Polling.poll @ polling.js:118
./node_modules/engine.io-client/lib/transports/polling.js.Polling.doOpen @ polling.js:63
./node_modules/engine.io-client/lib/transport.js.Transport.open @ transport.js:83
./node_modules/engine.io-client/lib/socket.js.Socket.open @ socket.js:248
Socket @ socket.js:121
Socket @ socket.js:28
./node_modules/socket.io-client/lib/manager.js.Manager.open.Manager.connect @ manager.js:226
(anonymous) @ manager.js:540
polling-xhr.js:265 GET https://localhost:4000/socket.io/?EIO=3&transport=polling&t=MTuEOt8 net::ERR_CERT_AUTHORITY_INVALID

Blank page after authentification

I'm trying to integrate you approach into my react app . I get the twitter authentication popup and it does seems to work correctly but after the authorization and the authentication the popup stuck in a blank page with this url :
127.0.0.1:8080/twitter/callback?oauth_token=xxx&oauth_verifier=xxx

Request tweets

Hi, i have managed to complete the authorisation stage of this tutorial, i guess this isnt really an issue but would like help or maybe help directing me to a site displaying how to fetch/request tweets once the callback has been executed and has been authorised/logged-in.

I have been on the twitter site and copied the code here : https://developer.twitter.com/en/docs/labs/tweets-and-users/quick-starts/get-tweets
and refactored to look like this on a separate twitter.js file to be imported into the App.js (App component). Heres my code:

///////////////////////////////////////start///////////////////////////////////////////////
tweet.js file

import React, { Component } from 'react';
const request = require('request');

const util = require('util')
const get= util.promisify(request.get);
const endpointURL = new URL('https://api.twitter.com/labs/1/tweets');

export default class Tweets extends Component {
state={
tweets:''
}
componentDidMount(){
async function getRequest(){
const params = {
ids: 'TLgXKh7bO0H_t9DeAAAq',
format: 'detailed',
};
const req = await get({url:endpointURL, qs: params, json:true, mode: 'cors'});
if( req.body ){
return req.body;

} else {
 console.log('not working working')
}

}

(async ()=>{
try{
const response = await getRequest();
console.log(response);
} catch(e){
console.error( e)
}
})();
}

render() {
return(



    {this.state.tweets
    ? this.state.tweets.map(el=>(
  • {el}
  • ))
    :
    Didnt fetch
    }


)
}
}

////////////////////////////////////////end//////////////////////////////////////////////

This is imported to the App.js file as such:

////////////////////////////////////////start//////////////////////////////////////////////
App.js fiile:

import React, { Component } from 'react'
import io from 'socket.io-client'
import OAuth from './OAuth'
import Loading from './Loading'
import Footer from './Footer'
import Tweets from './Tweets'
import { API_URL } from './config'
import './App.css'
const socket = io(API_URL) //,{transports: ['websocket']}
const providers = ['twitter', 'google', 'facebook', 'github']//import theese in because our auth controller needs to call our event for each provider which the event is named after the provider

export default class App extends Component {

state = {
loading: true
}

componentDidMount() {//check server and server route is working as created on server.js so to remove loading screen

socket.on('connect', function(){
  console.log('connected')
});

fetch(`${API_URL}/wake-up`)
  .then(res => {
    if (res.ok) {
      this.setState({loading: false})
    }
  })

}

render() {
const divStyles = {

}
const buttons = (providers, socket) =>
  providers.map(provider =>
    <OAuth
      provider={provider}
      key={provider}
      socket={socket}
    />
  )

return (
  <div className='wrapper'>
    <div className='container'>
      {this.state.loading
        ? <Loading />
        : buttons(providers, socket)
      }
    </div>

{
buttons
?
:

Hasnt fetched

}


)
}
}

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.