我使用的是Google Web Components的google-signin元素,但我不知道如何返回用户信息。google-signin不返回用户信息
<google-signin
client-id="{{my-id}}" scopes="email profile"
signed-in="{{signedIn}}"></google-signin>
我试图写一些JS函数,但它没有工作。
function (signedIn) {
var profile = gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile();
console.log('Name: ' + profile.getName());
console.log('Image: ' + profile.getImageUrl());
}
对不起,如果这是愚蠢的问题,但我不擅长网络开发。 谢谢你的建议。
感谢传感器,很好的解释。当我在浏览器中运行它时,我成功地获得了google-signin-aware的工作和功能,但是当我在设备上运行它时,我在handleSignIn中获得了以下内容:“Uncaught TypeError:无法读取null属性'currentUser' 。当我通过Android Studio运行它时,或者在将我的客户端ID更改为Android之后生成签名的apk时,会发生这种情况。任何帮助表示赞赏。 –