funador / react-auth-server Goto Github PK
View Code? Open in Web Editor NEWSocial authentication with React and Express
Social authentication with React and Express
does not seem to work. https://react-auth-twitter.netlify.com/ does not log in... i thought it did before, but it seems to have stopped
/Users/maherbhavsar/webprj/react-auth-server/node_modules/passport-oauth1/lib/strategy.js:83
if (!options.consumerKey) { throw new TypeError('OAuthStrategy requires a consumerKey option'); }
I was having a lot difficult to implement social login with my app, and you have already helped a lot, thanks! and I have already prototyped my own version and it works!
But how would you recommend me to make a middleware to check if the access_token being sent from my frontend is valid?
I am aware about google tokeninfo route that returns some data if we send a valid access_token and facebook has the sema approach. would you recommend to validate the request using those routes or there is something else?
google route: /oauth2/v1/tokeninfo?access_token=accessToken
facebook route: /me?access_token=xxxxxxxxxxxxxxxxx
github: GET /applications/:client_id/tokens/:access_token
sorry if I sound like noob, but I am :D
Hi,
When I cloned the server repo and run npm install
and npm start
, it gives me the error:
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
no such file or directory, open '...\react-auth-server\certs\server.key'.
Hello,
I have integrated your approach into my application and it appears to work well for Twitter, Google and Github. Your version works when i check it out and run it on my local machine.
When running my version of the code, i find that Facebook fails. Your repo is different from the article and i have followed the changes from the repo with the middleware for session storage.
The facebook user is returned and i can see the data in the console if i output it. However, the session does not contain the socket Id.
Is there anything special about Facebook which might be wrong here? I am using HTTPS.
Outputting the values
Logging the socketId in the router middleware.
router.use((req, res, next) => {
console.log("Add socket to session");
console.log(req.query.socketId);
req.session.socketId = req.query.socketId
next()
})
Logging the socketId in the callback.
exports.facebook = (req, res) => {
const io = req.app.get('io')
const { givenName, familyName } = req.user.name
const user = {
name: `${givenName} ${familyName}`,
photo: req.user.photos[0].value
}
console.log("Facebook user");
console.log(req.session.socketId); // This returns as undefined!
io.in(req.session.socketId).emit('facebook', user);
res.end();
}
Output for Google
[0] Add socket to session
[0] WuBItRcIskcXEy02AAAB
[0] Google user
[0] WuBItRcIskcXEy02AAAB
Output for Facebook
[0] Add socket to session
[0] WuBItRcIskcXEy02AAAB
[0] Facebook user
[0] undefined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.