问题
How do I trigger the Google Sign In authorization window to popup?
I'm using JaredHanons' "passport-google-oauth20" library to help with authentication on an application in combination with JSON WebTokens.
My frontend is a single page application with react. I currently have a node.js/express.js api backend and, right now, a separate frontend dev server with react. Frontend wise I have a login button calling:
axios.get("http://localhost:3000/oauth/google/getToken/")
Which is hitting:
`app.get(
"/oauth/google/getToken",
passport.authenticate("google", {
scope: ["profile"]
})
);`
After it hits the api end point is sends a response with a data value with the RAW Google HTML!{
data: "<!DOCTYPE html...";
status: 200;
}
If type api endpoint in the browser url bar localhost:8080/oauth/google/getToken it loads the raw GoogleSignIn window like I want it to. Is there anyway to redirect to this page on the frontend instead of getting raw html?
来源:https://stackoverflow.com/questions/54272944/how-to-use-passport-google-oauth20-with-a-spa-react-application