Рубрики
Без рубрики

Google Popup Войти с React и Firebase

Настройка конфигурации Firebase: var firebaseconfig = {apikey: “Супер секретные клавиши ….. asgve … Теги с реакцией, JavaScript, Firebase.

var firebaseConfig = {
    apiKey: "super secret keys.....asgvegxgevergfvr",
    authDomain: "tallans-imageupload-tutorial.firebaseapp.com",
    databaseURL: "https://tallans-imageupload-tutorial.firebaseio.com",
    projectId: "tallans-imageupload-tutorial",
    storageBucket: "tallans-imageupload-tutorial.appspot.com",
    messagingSenderId: "super secret keys.....asgvegxgevergfvr",
    appId: "super secret app id....adsfa;lsdkjf",
    measurementId: "super secret as;dlkfjal;dskjf"
  };
  // Initialize Firebase
  firebase.initializeApp(firebaseConfig);
  firebase.analytics();
make npx-create-react-app client
and ::
npm i or yarn add firebase 
and react-router-dom

сейчас::

cd client 
cd src
mkdir componets/login.js

==========

import React from 'react'
import './App.css'
import Login from './components/Login'
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'
import Logout from './components/Logout'
import Welcome from './components/Welcome'
const App = () => {
  return (
    
) } export default App
import React from 'react'
import firebase from '../services/firebase'
import {useHistory} from 'react-router-dom'
import './Login.css'
const Login = () => {
const history = useHistory();
    const signInWithGoogle = () => {
        const provider = new firebase.auth.GoogleAuthProvider();
        firebase.auth().signInWithPopup(provider)
            .then((success) => {

                let user = success.user;

                const obj = {
                    username : user.displayName,
                    email:user.email,
                    uid:user.uid,
                    img:user.photoURL
                }
                console.log(obj)
                localStorage.setItem('codecaamp',JSON.stringify(obj))
                history.push('/welcome')
            })
            .catch(err => err.message)
    }

    return (
        
codecaamp

Welcome to Codecaamp

Continue With

) } export default Login

Оригинал: “https://dev.to/mrmorsalin1/google-popup-sign-in-with-react-and-firebase-2oh1”