使用谷歌登录,获取大型个人资料图片

Login with google get large profile picture

本文关键字:大型 资料图片 获取 谷歌 登录      更新时间:2023-09-26

我用这段代码在我的网站上实现谷歌登录。

<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script>
function onSignIn(googleUser) {
  var profile = googleUser.getBasicProfile();
  console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
  console.log('Name: ' + profile.getName());
  console.log('Image URL: ' + profile.getImageUrl());
  console.log('Email: ' + profile.getEmail());
}
</script>

但我在控制台上得到了小的个人资料图片。如何从谷歌获取最大个人资料图片的url?

是否将查询参数添加到imageurl?sz=x,其中x是您的图像大小。

基本回答在这里

从Google+API 检索配置文件图像