<code>passport.use(
new GoogleStrategy({
clientID:"xyz.apps.googleusercontent.com",
clientSecret:"xyz",
callbackURL:'http://localhost:5173/loggedin'
},
(accessToken, refreshToken, profile, done)=>{
console.log(profile)
})
)
</code>
<code>passport.use(
new GoogleStrategy({
clientID:"xyz.apps.googleusercontent.com",
clientSecret:"xyz",
callbackURL:'http://localhost:5173/loggedin'
},
(accessToken, refreshToken, profile, done)=>{
console.log(profile)
})
)
</code>
passport.use(
new GoogleStrategy({
clientID:"xyz.apps.googleusercontent.com",
clientSecret:"xyz",
callbackURL:'http://localhost:5173/loggedin'
},
(accessToken, refreshToken, profile, done)=>{
console.log(profile)
})
)
Here’s the react router code in which i wanna use above passport authenticate middlware:
<code><Router>
<Routes>
<Route path="/" element={<App/>}/>
<Route path="/loggedin" element={<LoginPage/>}/>
</Routes>
</Router>
</code>
<code><Router>
<Routes>
<Route path="/" element={<App/>}/>
<Route path="/loggedin" element={<LoginPage/>}/>
</Routes>
</Router>
</code>
<Router>
<Routes>
<Route path="/" element={<App/>}/>
<Route path="/loggedin" element={<LoginPage/>}/>
</Routes>
</Router>
Here’s code for express server:
<code>app.get('/', passport.authenticate('google', {
scope: ['profile']
}))
app.get('http://localhost:5173/loggedin', passport.authenticate('google'),(req, res)=>{
res.send("logged in") //there is the issue
})
app.listen(3000, ()=>console.log("http://localhost:3000"))
</code>
<code>app.get('/', passport.authenticate('google', {
scope: ['profile']
}))
app.get('http://localhost:5173/loggedin', passport.authenticate('google'),(req, res)=>{
res.send("logged in") //there is the issue
})
app.listen(3000, ()=>console.log("http://localhost:3000"))
</code>
app.get('/', passport.authenticate('google', {
scope: ['profile']
}))
app.get('http://localhost:5173/loggedin', passport.authenticate('google'),(req, res)=>{
res.send("logged in") //there is the issue
})
app.listen(3000, ()=>console.log("http://localhost:3000"))
redirect url(‘http://localhost:5173/loggedin’) is added to google consent api.
Im tryna get user info with redirected to react page by getting req on express route for further processing. How to proceed?
New contributor
Shrikrishna Sawangikar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.