gsh*_*rew 3 google-oauth reactjs google-signin
我尝试使用react-google-login库,但现在谷歌限制开发人员使用它。所以现在我使用推荐的来获取用户信息。但问题是,它只打印到控制台 { clientId, credential, select_by }字段,那么我如何从响应对象中获取姓名、电子邮件和个人资料?
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;
Run Code Online (Sandbox Code Playgroud)
请记住我使用了正确的 ClientId。
| 归档时间: |
|
| 查看次数: |
4038 次 |
| 最近记录: |