I am trying to get the locations list of a user with Google My Business Javascript API ( https://developers.google.com/my-business/quickstarts/javascript ). A user logs in successfully with his google credentials and oauth token is generated. But When I am trying to get the locations--->
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();
I am getting null in xhr.response object.
It is somehow late to answer but in case somebody needs: If you do not have the error then probably, just the account has no locations. first check the google response in [https://developers.google.com/oauthplayground/], trying to see if you have the different response.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.