简体   繁体   English

当用户使用其Google+帐户唱歌时,我可以获取所有数据,但不能发送电子邮件。 email = null和verify_email = false

[英]When User sing in with their Google+ account, I can get all data, but only can't email. email=null and verified_email=false

     string URL=string.Format("https://www.googleapis.com/oauth2/v1/userinfo?access_token={0}", googleresponse.access_token);

  private A GetGoogleUser<A>(string urluser) where A:class
        {
           A user = null;
            if (googleresponse != null && !string.IsNullOrEmpty(googleresponse.access_token))
            {                
                HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(urluser);
                HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
                if (((HttpWebResponse)webresponse).StatusCode == HttpStatusCode.OK)
                {
                    using (Stream recieveuser = webresponse.GetResponseStream())
                    {
                        Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
                        using (StreamReader readstream = new StreamReader(recieveuser, encode))
                        {
                            user = new JavaScriptSerializer().Deserialize<A>(readstream.ReadToEnd());
                            webresponse.Close();
                            readstream.Close();
                        }
                    }
                }                 
            }
            return  user;
        }

It is code that I can get User data When User sign in with their Google+ account to my website. 当用户使用其Google+帐户sign in我的网站时,我可以获取该数据。 Everthing is fine. 一切都很好。 I can get User data (id,name,gender,picture,link,family_name,locale) , but only I can't email. 我可以获取用户数据(id,name,gender,picture,link,family_name,locale) ,但只有我无法发送电子邮件。

email=null
verified_email=false

But yesterday it was not so. 但是昨天并非如此。 I could get email too. 我也可以收到email

Does anyone know that where is my mistake ? 有谁知道我的错误在哪里?

@@@. @@@。 . . I used only https://www.googleapis.com/auth/plus.profile.emails.read as scope , and string URL=string.Format("https://www.googleapis.com/plus/v1/people/me?access_token={0}‌​‌​", googleresponse.access_token); 我仅使用https://www.googleapis.com/auth/plus.profile.emails.read作为scopestring URL=string.Format("https://www.googleapis.com/plus/v1/people/me?access_token={0}‌​‌​", googleresponse.access_token); for creating HttpWebRequest . 用于创建HttpWebRequest I can get all user's data, also email . 我可以获取所有用户数据,也可以获取email

I wrote this here because may be other users can be use. 我在这里写这个是因为可能被其他用户使用。

You also need the https://www.googleapis.com/auth/plus.profile.emails.read scope. 您还需要https://www.googleapis.com/auth/plus.profile.emails.read范围。 See https://developers.google.com/+/web/people/#retrieve_an_authenticated_users_email_address and https://developers.google.com/+/api/oauth#email-scopes for more details. 有关更多详细信息,请参见https://developers.google.com/+/web/people/#retrieve_an_authenticated_users_email_addresshttps://developers.google.com/+/api/oauth#email-scopes

Update 更新资料

To be clear, you still need the https://www.googleapis.com/auth/plus.login scope in addition to the plus.profile.emails scope I mentioned above. 需要明确的是,除了上面提到的plus.profile.emails范围外,您还需要https://www.googleapis.com/auth/plus.login范围。

You'll still use the plus.people.get endpoint described at https://developers.google.com/+/api/latest/people/get 您仍将使用https://developers.google.com/+/api/latest/people/get中描述的plus.people.get端点

You should no longer use the userinfo endpoint - those have been deprecated and will be removed in September. 您不应再使用userinfo终结点-已弃用了这些终结点,并将在9月将其删除。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以使用此逻辑来获取Google帐户的电子邮件地址(使用Google+ API(人)) - May I use this logic to get the Google Account email address (using Google+ API (People) ) 如何在ASP.NET 4.5 C#中通过OWIN访问Google+用户的电子邮件和图片地址? - How can I access Google+ user's email and pictures address through OWIN in ASP.NET 4.5 C#? 如何从 outlook email 帐户获取数据,例如电子邮件、联系人和日历事件,并将其显示在列表中? - How can I get the data from an outlook email account, such as emails, contacts, and calendar events, and show it inside a list? 为什么我在尝试发送 SES email 时收到“消息被拒绝:Email 地址未验证”? - Why do I get 'Message rejected: Email address is not verified' when trying to send an SES email? email =null 和 VerifiedEmail=false 谷歌访问令牌 - email =null and VerifiedEmail=false google access token 无法获得在MVC 5项目中工作的用户帐户的电子邮件验证? - Can't get email verification on user accounts working in mvc 5 project? 用户回复电子邮件。 您如何从用户电子邮件中获取数据? - user replying to email messages. How can you get data from users email? 获取会员用户电子邮件(如果不为null) - Get membership user email if not null 如何使用google+ api获取朋友的电子邮件? - How to get Email of friend using google+ api? 当用户验证电子邮件C#时,将sql表更新为已验证 - update sql table as verified when user verifies their email c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM