【问题标题】:React: get user phone numberReact:获取用户电话号码
【发布时间】:2018-04-10 17:46:43
【问题描述】:

我正在开发 React js 应用程序,用户可以使用谷歌帐户登录,我想通过使用 firebase 登录来检索用户的注册电话号码。

我已按照本教程制作登录流程
https://github.com/firebase/firebaseui-web-react

我的问题是:当他/她时我可以得到用户的电话号码吗? 使用谷歌电子邮件登录我的系统?

这是我用来登录的部分代码

firebase_ui_instance.start('#firebaseui-auth-container', {
                signInFlow:'popup',
                signInOptions: [ {
                        provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
                        // Required to enable this provider in one-tap sign-up.
                        authMethod: 'https://accounts.google.com',
                        scopes: [
                            'https://www.googleapis.com/auth/plus.login',
                            'https://www.googleapis.com/auth/userinfo.profile',
                            'https://www.googleapis.com/auth/user.phonenumbers.read'
                        ],
                        customParameters: {
                            // Forces account selection even when one account
                            // is available.
                            prompt: 'select_account'
                        },
                        // Required to enable ID token credentials for this provider.
                        // This can be obtained from the Credentials page of the Google APIs
                        // console.

                        clientId: '[MY_CLIENT_ID]',
                        credentialHelper: firebaseui.auth.CredentialHelper.GOOGLE_YOL

                    }

我能够获得有关用户的许多信息(电子邮件、全名...),但不能获得手机号码...

【问题讨论】:

    标签: reactjs firebase google-api google-oauth


    【解决方案1】:

    您是否尝试过此页面上的 API 并尝试在右侧执行查询? https://developers.google.com/people/api/rest/v1/people/get

    您将获得访问令牌,并且您需要使用它来进行 API 调用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多