Javascript 如何使用谷歌访问令牌获取电子邮件地址?
我无法从回复中获取电子邮件id 答复如下:Javascript 如何使用谷歌访问令牌获取电子邮件地址?,javascript,google-chrome-extension,oauth-2.0,Javascript,Google Chrome Extension,Oauth 2.0,我无法从回复中获取电子邮件id 答复如下: { "id": "00000000000000", "name": "Fred Example", "given_name": "Fred", "family_name": "Example", "picture": "https://lh5.googleusercontent.com/-2Sv-4bBMLLA/AAAAAAAAAAI/AAAAAAAAABo/bEG4kI2mG0I/photo.jpg", "locale": "
{
"id": "00000000000000",
"name": "Fred Example",
"given_name": "Fred",
"family_name": "Example",
"picture": "https://lh5.googleusercontent.com/-2Sv-4bBMLLA/AAAAAAAAAAI/AAAAAAAAABo/bEG4kI2mG0I/photo.jpg",
"locale": "en"
}
这就是我正在使用的:
https://www.googleapis.com/oauth2/v1/userinfo?access_token=“+令牌
您可能需要不同的作用域。根据文件,范围<代码>https://www.googleapis.com/auth/userinfo.profile允许您查看基本配置文件信息。要查看电子邮件,您需要以下范围:https://www.googleapis.com/auth/userinfo.email
现在我可以在respone中获取电子邮件,下面是代码,我在其中更改了清单中的响应
"oauth2": {
"client_id": "854569859639-9c0reicivklkv0ltpakv99iajqts5obs.apps.googleusercontent.com",
"scopes": [ "https://www.googleapis.com/auth/userinfo.email" ]}
我更改了范围“范围”:https://www.googleapis.com/auth/plus.login“]
至“范围”:[“https://www.googleapis.com/auth/userinfo.email“]
下面是回应
"{
"id": "00000000000000",
"name": "Fred Example",
"email":"abc@xyz.com",
"given_name": "Fred",
"family_name": "Example",
"picture": "https://lh5.googleusercontent.com/-2Sv-4bBMLLA/AAAAAAAAAAI/AAAAAAAAABo/bEG4kI2mG0I/photo.jpg",
"locale": "en"
}"
非常感谢,先生,现在我得到了电子邮件地址。现在我可以收到电子邮件了,下面是回复
“{”id:“00000000000000”,“email:“abc.xyz.com”,“name:“Fred Example”,“given_name:“Fred”,“family_name:“Example”,“picture:”https://lh5.googleusercontent.com/-2Sv-/photo.jpg“,”语言环境“:“en”}”
,使用此响应如何检索电子邮件?var email=JSON.parse(response)[“email”]代码>@IvánNokonoko嗨,我也有同样的信息。使用https://www.googleapis.com/auth/userinfo.email.
我收到的回复是“userinfo.email”。请help@Gowrihttps://www.googleapis.com/auth/userinfo.email
不是API端点,而是范围。您必须向其发送授权请求的API端点是https://www.googleapis.com/auth/userinfo
。对于我来说,没有收到“userinfo.email”的回复。请帮忙