如何解决如何使用一键登录获取已在我的Web应用程序上注册的所有用户的访问令牌
当某人被授予使用gmb Web应用程序的访问权限时,我正在尝试获取用户的访问令牌。我在进行测试时可以进行控制台操作,但无法检索获得访问权限的用户的帐户我的平台,我也想知道我如何才能找到用户。 在这里,我正在使用Google一键登录
<div
id="g_id_onload"
data-client_id="xxxx.apps.googleusercontent.com"
data-callback="handleResponse"
></div>
这是handleResponse
function handleCredentialResponse(response) {
const config = {
scope: "https://www.googleapis.com/auth/plus.business.manage",client_id:
"xxx.apps.googleusercontent.com",};
gapi.auth2.authorize(config,function (response) {
var requestOptions = {
method: "GET",redirect: "follow",};
console.log(response.access_token);
fetch(
`https://mybusiness.googleapis.com/v4/accounts?access_token=${response.access_token}`,requestOptions
)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error",error));
});
}
我正在使用此代码获取所有帐户
var requestOptions = {
method: 'GET',redirect: 'follow'
};
fetch("https://mybusiness.googleapis.com/v4/accounts",requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error',error));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。