React
function GoogleLogin() {
const handleLogin = () => {
const width = 500;
const height = 600;
const left = window.screen.width / 2 - width / 2;
const top = window.screen.height / 2 - height / 2;
const popup = window.open(
'https://api.superbox.ai/v1/auth/oauth/google',
'Google Login',
`width=${width},height=${height},left=${left},top=${top}`
);
// Listen for callback
window.addEventListener('message', (event) => {
if (event.data.type === 'oauth_success') {
const { token, user } = event.data;
// Store token and update UI
}
});
};
return (
<button onClick={handleLogin}>
Sign in with Google
</button>
);
}