【发布时间】:2022-09-29 19:15:51
【问题描述】:
我尝试使用 react-google-login 库,但现在谷歌限制开发人员使用它。所以现在我使用推荐的一个来获取用户信息。但问题是,它只打印到控制台{ 客户标识, 凭据, 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;
记住我使用了正确的 ClientId。
标签: reactjs google-oauth google-signin