我目前正在使用Google_Client api并想要获取用户名,电话,电子邮件和用户地址.
我设置了这些范围:
'https://www.googleapis.com/auth/plus.login',
'https://www.googleapis.com/auth/user.birthday.read',
'https://www.googleapis.com/auth/user.addresses.read',
'https://www.googleapis.com/auth/user.emails.read',
'https://www.googleapis.com/auth/user.phonenumbers.read'
Run Code Online (Sandbox Code Playgroud)
当我点击google登录时,它会询问正确的权限,然后我会使用Google提供的代码获取访问令牌.
获取我请求的令牌people_service和配置文件数据后,如下所示:
$token = $this->client->fetchAccessTokenWithAuthCode($_GET['code']);
$people_service = new \Google_Service_PeopleService($this->client);
$profile = $people_service->people->get(
'people/me',
array('personFields' => 'addresses,birthdays,emailAddresses,phoneNumbers')
);
Run Code Online (Sandbox Code Playgroud)
它返回一个Google_Service_PeopleService_Person对象.
但是,当我尝试使用它时,就像getPhoneNumbers()它返回一个 Call to undefined method Google_Service_PeopleService_Person::getNames()错误.
有什么问题,我该怎么办?
我正在尝试实现“使用 Google 登录”按钮,如下所述: https: //developers.google.com/identity/gsi/web/guides/display-button
我对它的期望感到困惑data-login_uri,如下所示(取自上面链接的文档):
<div id="g_id_onload"
data-client_id="YOUR_GOOGLE_CLIENT_ID"
data-login_uri="https://your.domain/your_login_endpoint"
data-auto_prompt="false">
</div>
Run Code Online (Sandbox Code Playgroud)
我已正确配置应用程序的客户端 ID,并且可以完成 Google 弹出窗口提供的大部分登录/身份验证流程。但是,一旦弹出窗口关闭,它就会尝试POST到我指定为data-login_uri.
这让我相信我们需要一个后端端点来做......某事......但我无法找到有关此端点应该如何表现的任何文档,因此我不确定有什么要求与我的后端开发人员沟通。
我错过了什么?
authentication google-authentication google-account google-client-login google-signin
我正在尝试使用 javascript 客户端 API 为 youtube 实现可恢复的上传。我已经设法使用g-signin2按钮使登录正常工作,但我无法获取与请求一起发送的 access_token。这就是我呈现登录按钮的方式:
<span
class="g-signin2"
data-onsuccess="youtubeUploaderSigninCallback"
data-scope="https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtube">
</span>
Run Code Online (Sandbox Code Playgroud)
我正在使用从谷歌加载的以下脚本文件(如果没有另一个我似乎无法工作)
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://apis.google.com/js/client.js" async defer></script>
Run Code Online (Sandbox Code Playgroud)
我正在使用来自https://developers.google.com/youtube/v3/code_samples/javascript#upload_video 的代码编辑示例来使用 XHR 进行可恢复的上传。但是这些示例使用此处标记为已弃用的身份验证函数:https : //developers.google.com/api-client-library/javascript/reference/referencedocs
所以我更改的主要内容是使用auth2andg-signin2而不是result.access_tokenand g-signin。
所以我一直在尝试使用auth2函数来获取访问令牌,但是access_token当我执行以下代码时该属性未定义
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse()
Run Code Online (Sandbox Code Playgroud)
我尝试获取访问令牌的方式记录在此处:https : //developers.google.com/api-client-library/javascript/features/cors#making-authenticated-requests
所以这些是我的选择,我想:
hg确实是一个缩小的财产,现在不再存在谁能帮我这个?几个小时以来,我一直在寻找可接受的解决方案,现在我想哭……孤单和绝望。
提前致谢,罗布