some sort of google oauth popup working at least

This commit is contained in:
talksik
2022-05-28 09:44:27 -05:00
parent fb9a42f277
commit 0558df4f03
5 changed files with 636 additions and 393 deletions
+2 -2
View File
@@ -98,11 +98,11 @@
"@mui/icons-material": "^5.8.0",
"@mui/material": "^5.8.1",
"electron-squirrel-startup": "^1.0.0",
"firebase": "^9.8.2",
"notistack": "^2.0.5",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "^4.3.1",
"react-use": "^17.4.0",
"realm": "^10.17.0"
"react-use": "^17.4.0"
}
}
+10 -1
View File
@@ -1 +1,10 @@
export const firebase = '';
// eslint-disable-next-line import/no-unresolved
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
// eslint-disable-next-line @typescript-eslint/no-var-requires
import devConfig from './config/firebase.dev.config.json';
export const firebaseApp = initializeApp(devConfig);
export const firebaseAuth = getAuth(firebaseApp);
@@ -1,14 +1,18 @@
import { Button, Container } from '@mui/material';
import React, { useContext, useEffect, useCallback } from 'react';
import Realm from 'realm';
import { FcGoogle } from 'react-icons/fc';
import { blueGrey } from '@mui/material/colors';
import Channels from '../electron/constants';
import { firebase } from '../firebase/connect';
import { firebaseAuth } from '../firebase/connect';
import { GoogleAuthProvider, signInWithPopup } from 'firebase/auth';
const provider = new GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/contacts.readonly');
interface IAuthContext {
user?: Realm.User;
user?: any;
}
const AuthContext = React.createContext<IAuthContext>({});
@@ -31,7 +35,29 @@ const Login = () => {
// take user to browser to complete authentication
const handleLogin = useCallback(() => {
// send to main process
window.electronAPI.auth.initiateLogin();
// window.electronAPI.auth.initiateLogin();
signInWithPopup(firebaseAuth, provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
// The signed-in user info.
const user = result.user;
console.log(result);
// ...
})
.catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
}, []);
return (
+594 -386
View File
File diff suppressed because it is too large Load Diff