<script src="https://accounts.google.com/gsi/client"></script>
...
declare var google: any;
...
useEffect(() => {
const handleCredentialResponse = (response: any) => {
console.log(response);
};
const client_id = process.env.REACT_APP_GOOGLE_CLIENT_ID;
const callback = handleCredentialResponse;
const auto_select = true;
google.accounts.id.initialize({ client_id, callback, auto_select });
google.accounts.id.prompt((notification: any) => {
console.log(notification);
});
}, []);
为什么根本handleCredentialResponse
没有被调用?用户被提示登录,他们点击继续,然后该函数永远不会被调用!呸!以上取自此处和此处的文档
该notification
注销
nl {g: "display", h: true}
nl {g: "skipped", l: "issuing_failed"}