完全自定义Google SSO按钮
我写了流动的代码给Google SSO的身份用户, 但是,当我使用Google API时,它将他们的iframe推向我的代码,并破坏我的项目的样式! 有人知道一种方法来定义一个单独的按钮,例如下面的代码,当单击它时,Google SSO auth页面将为用户打开?
const googleSSO = (e: { preventDefault: () => void }) => {
e.preventDefault();
console.log(google);
// google.accounts.id.renderButton(document.getElementById('singInDiv'), {
// theme: 'outline',
// size: 'large',
// type: 'icon'
// });
return google.accounts.id.initialize({
client_id:
'myclientID.apps.googleusercontent.com',
callback: handleCallbackResponse
});
};
return (
<>
<IconButton sx={{ ml: 1, mb: 0.5 }} onClick={googleSSO} color="primary">
<GoogleIcon />
</IconButton>
<IconButton sx={{ ml: 1, mb: 0.5 }} onClick={googleSSO} color="primary">
<GitHubIcon />
</IconButton>
<IconButton sx={{ ml: 1, mb: 0.5 }} onClick={googleSSO} color="primary">
<FacebookIcon />
</IconButton>
</>
);
i wrote flowing code to auth user by google sso,
but when i used google api, it push their iframe in my code and spoils the style of my project!!
Does anyone know a way to define a separate button like the code below and when it is clicked, the google sso auth page will open for the user?
const googleSSO = (e: { preventDefault: () => void }) => {
e.preventDefault();
console.log(google);
// google.accounts.id.renderButton(document.getElementById('singInDiv'), {
// theme: 'outline',
// size: 'large',
// type: 'icon'
// });
return google.accounts.id.initialize({
client_id:
'myclientID.apps.googleusercontent.com',
callback: handleCallbackResponse
});
};
return (
<>
<IconButton sx={{ ml: 1, mb: 0.5 }} onClick={googleSSO} color="primary">
<GoogleIcon />
</IconButton>
<IconButton sx={{ ml: 1, mb: 0.5 }} onClick={googleSSO} color="primary">
<GitHubIcon />
</IconButton>
<IconButton sx={{ ml: 1, mb: 0.5 }} onClick={googleSSO} color="primary">
<FacebookIcon />
</IconButton>
</>
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论