<bdo id='zBpPV'></bdo><ul id='zBpPV'></ul>

      <legend id='zBpPV'><style id='zBpPV'><dir id='zBpPV'><q id='zBpPV'></q></dir></style></legend>
      1. <small id='zBpPV'></small><noframes id='zBpPV'>

        <i id='zBpPV'><tr id='zBpPV'><dt id='zBpPV'><q id='zBpPV'><span id='zBpPV'><b id='zBpPV'><form id='zBpPV'><ins id='zBpPV'></ins><ul id='zBpPV'></ul><sub id='zBpPV'></sub></form><legend id='zBpPV'></legend><bdo id='zBpPV'><pre id='zBpPV'><center id='zBpPV'></center></pre></bdo></b><th id='zBpPV'></th></span></q></dt></tr></i><div id='zBpPV'><tfoot id='zBpPV'></tfoot><dl id='zBpPV'><fieldset id='zBpPV'></fieldset></dl></div>

        <tfoot id='zBpPV'></tfoot>

        Google OAuth2 登录 - 获取 YouTube 昵称和真实电子邮件地址

        Google OAuth2 Login - Get YouTube nickname and real email address(Google OAuth2 登录 - 获取 YouTube 昵称和真实电子邮件地址)
          • <small id='e6FKw'></small><noframes id='e6FKw'>

          • <tfoot id='e6FKw'></tfoot>
            <legend id='e6FKw'><style id='e6FKw'><dir id='e6FKw'><q id='e6FKw'></q></dir></style></legend>
              • <bdo id='e6FKw'></bdo><ul id='e6FKw'></ul>
              • <i id='e6FKw'><tr id='e6FKw'><dt id='e6FKw'><q id='e6FKw'><span id='e6FKw'><b id='e6FKw'><form id='e6FKw'><ins id='e6FKw'></ins><ul id='e6FKw'></ul><sub id='e6FKw'></sub></form><legend id='e6FKw'></legend><bdo id='e6FKw'><pre id='e6FKw'><center id='e6FKw'></center></pre></bdo></b><th id='e6FKw'></th></span></q></dt></tr></i><div id='e6FKw'><tfoot id='e6FKw'></tfoot><dl id='e6FKw'><fieldset id='e6FKw'></fieldset></dl></div>

                    <tbody id='e6FKw'></tbody>
                  本文介绍了Google OAuth2 登录 - 获取 YouTube 昵称和真实电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有什么办法可以将用户的 youtube 昵称与他的真实 (*@gmail.com) 电子邮件地址一起获取?

                  Is there any way to get the users youtube nickname together with his REAL (*@gmail.com) email address?

                  每当我要求 google 以youtube.readonly"范围对用户进行身份验证时,电子邮件地址都会更改为*@pages.plusgoogle.com".但是当我离开 YouTube 范围时,我不会得到 YouTube 昵称...

                  Whenever I ask google to authenticate the user with "youtube.readonly" scope, the email address changes to "*@pages.plusgoogle.com". But when I leave out the YouTube scope I do not get the YouTube nickname...

                  由 Google API PHP 客户端执行的请求 (https://github.com/google/google-api-php-client)

                  1.正确的电子邮件地址/错误的姓名:

                  范围:

                  https://www.googleapis.com/auth/userinfo.email
                  https://www.googleapis.com/auth/userinfo.profile
                  

                  用户信息:

                  email: "********@gmail.com"         //<- I need this
                  family_name: <My last name>
                  given_name: <My first name>
                  name: <My full name>
                  verified_email: true
                  [...]
                  

                  2.错误的电子邮件/正确的姓名:

                  范围:

                  https://www.googleapis.com/auth/userinfo.email
                  https://www.googleapis.com/auth/userinfo.profile
                  https://www.googleapis.com/auth/youtube.readonly
                  

                  用户信息:

                  email: "<My YT nickname>-<Random(?) ID>@pages.plusgoogle.com"
                  family_name: "."
                  given_name: <My YT nickname>
                  name: <My YT nickname>              //<- and I need that
                  verified_email: true
                  [...]
                  

                  那么:如何在不更改范围的情况下从请求 #1 和请求 #2 的名称中获取电子邮件(需要重新进行身份验证)?

                  So: How to get the email from request #1 and the name of request #2 without changing the scopes (what requires re-authentication)?

                  $oauth2 = new Google_Service_Oauth2($google);
                  if (strlen($code) > 10) {
                      try {
                          $accessToken = $google->authenticate($code);
                      } catch (Google_Auth_Exception $e) {
                          return new false;
                      }
                  
                      if (!$accessToken) {
                          return false;
                      }
                  
                      $userinfo = $oauth2->userinfo->get();
                      var_dump($userinfo);die;
                  }
                  

                  转储 (使用 YT 范围)

                  object(Google_Service_Oauth2_Userinfo)[325]
                    public 'email' => string '***@pages.plusgoogle.com' (length=36) //wrong email..
                    public 'family_name' => string '.' (length=1)
                    public 'gender' => null
                    public 'given_name' => string '***' (length=10)
                    public 'hd' => null
                    public 'id' => string '1013***' (length=21)
                    public 'link' => string 'https://plus.google.com/1013***' (length=45)
                    public 'locale' => null
                    public 'name' => string '***' (length=10)
                    public 'picture' => string 'https://lh5.googleusercontent.com/***/photo.jpg' (length=92)
                    public 'timezone' => null
                    public 'verified_email' => boolean true
                    protected 'data' => 
                      array (size=0)
                        empty
                    protected 'processed' => 
                      array (size=0)
                        empty
                  

                  推荐答案

                  有趣的用例.不幸的是,目前没有办法用一个令牌来做到这一点.原因是 youtube 频道在系统中由不同的对象(几乎像用户帐户)表示.并且 OAuth 授权可以属于 gmail 用户或 youtube 频道.当我们在请求中看到 youtube 范围时,我们会显示用户 ID 和用户可能拥有的任何频道的列表,并且批准用户选择其中一个.生成的令牌属于该对象/帐户.

                  Interesting use case. Unfortunately there is no way to do this with one token at this time. The reason is that youtube channel is represented by a different object (almost like a user account) in the system. And an OAuth grant can belong to either the gmail user or the youtube channel. When we see the youtube scope in the request, we show a list of user id and any channels that the user may have and the approving user selects one of them. And the resulting token belongs to that object/account.

                  我们正在构建与委托和渠道相关的新功能.例如一种可能的解决方案可能是在用户帐户上获取一个令牌,使您可以访问由该帐户管理的所有渠道上的 API.抱歉,目前没有预计到达时间.

                  We are building new features related to delegation and channels. e.g. One possible solution may be to get a single token on the user account that gives you access to APIs on all channels that are managed by that account. Sorry, there is no ETA at this time.

                  这篇关于Google OAuth2 登录 - 获取 YouTube 昵称和真实电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <small id='IXwLN'></small><noframes id='IXwLN'>

                    • <legend id='IXwLN'><style id='IXwLN'><dir id='IXwLN'><q id='IXwLN'></q></dir></style></legend>

                        <bdo id='IXwLN'></bdo><ul id='IXwLN'></ul>
                          <tbody id='IXwLN'></tbody>
                        <tfoot id='IXwLN'></tfoot>

                        1. <i id='IXwLN'><tr id='IXwLN'><dt id='IXwLN'><q id='IXwLN'><span id='IXwLN'><b id='IXwLN'><form id='IXwLN'><ins id='IXwLN'></ins><ul id='IXwLN'></ul><sub id='IXwLN'></sub></form><legend id='IXwLN'></legend><bdo id='IXwLN'><pre id='IXwLN'><center id='IXwLN'></center></pre></bdo></b><th id='IXwLN'></th></span></q></dt></tr></i><div id='IXwLN'><tfoot id='IXwLN'></tfoot><dl id='IXwLN'><fieldset id='IXwLN'></fieldset></dl></div>