Chrome 扩展程序 identity.email 为空 [英] Chrome extension identity.email empty

查看:27
本文介绍了Chrome 扩展程序 identity.email 为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 chrome identity api 获取用户的电子邮件和 ID.

I am trying to get email and id of user through chrome identity api.

我正在这样做

  chrome.identity.getProfileUserInfo(function(userinfo){
    console.log("userinfo",userinfo);
    email=userinfo.email;
    uniqueId=userinfo.id;
  });

我已指定 identity 权限并在范围中添加了 https://www.googleapis.com/auth/userinfo.email.

I have specified identity permission and have added https://www.googleapis.com/auth/userinfo.email in scopes.

用户通过 chrome.identity.getAuthToken 登录,我有访问令牌.

User is logged in through chrome.identity.getAuthToken and I have access token.

console.log("userinfo",userinfo); 返回 userinfo Object {email: "", id: ""}

推荐答案

getProfileUserInfo 文档说:

  • 电子邮件:如果用户未登录或身份验证,则为空.电子邮件清单权限未指定.
  • id:如果用户未登录或(在 M41+ 中)未指定 identity.email 清单权限,则为空.
  • email: Empty if the user is not signed in or the identity.email manifest permission is not specified.
  • id: Empty if the user is not signed in or (in M41+) the identity.email manifest permission is not specified.

编辑 manifest.json 以包含两个权限:

Edit manifest.json to include both permissions:

"permissions": ["identity", "identity.email"]

这篇关于Chrome 扩展程序 identity.email 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆