retrive name, email and profile from@react-oauth-google (new react library)

Viewed 24

I tried using react-google-login library but now google ristricted developers from using this. so now i use the recommended one to get the user information. but the problem is, it just prints out to the console only { clientId, credential, select_by } fields so, how can i get name, email and profile from the response object?

import './App.css';
import React from 'react';
import { GoogleOAuthProvider } from '@react-oauth/google';
import { GoogleLogin } from '@react-oauth/google';
function App() {

  const clientId = "Client Id";
  const showUserInformation = (response) =>{
      console.log(response);
  }

  return (
    <div className="App">
    <GoogleOAuthProvider  clientId={clientId}>
    <GoogleLogin
        onSuccess={showUserInformation}
        onError={() => {
            console.log('Login Failed');
        }}
        />
    </GoogleOAuthProvider>
    </div>
  );
}


export default App;

remember i used the correct ClientId.

0 Answers
Related