我正在尝试使用 Google My Business Javascript API ( https://developers.google.com/my-business/quickstarts/javascript ) 获取用户的位置列表。用户使用他的 google 凭据成功登录并生成 oauth 令牌。但是当我试图获取位置时--->
var apiKey = 'xxxxxxxxxxxxxx';
var clientId = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var gmb_api_version = 'https://mybusiness.googleapis.com/v4';
let user = gapi.auth2.getAuthInstance().currentUser.get();
let oauthToken = user.getAuthResponse().access_token;
let xhr = new XMLHttpRequest();
let req = gmb_api_version + '/' + 'accounts/' + user.getId() + '/locations';
xhr.responseType = 'json';
xhr.open('GET', req);
xhr.setRequestHeader('Authorization', 'Bearer ' + oauthToken);
xhr.send();
我在 xhr.response 对象中得到空值。