I am trying to use google data studio apis from our web app.
I set up a local web server which returns html file at localhost:8081 (I updated apikey and client id got from our credentials console.)
Part of codes:
var apiKey = 'AXXX';
var discoveryDocs = ["https://datastudio.googleapis.com/$discovery/rest?version=v1"];
var clientId = 'XXX.apps.googleusercontent.com';
var scopes = 'https://www.googleapis.com/auth/datastudio https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile openid';
function makeApiCall() {
gapi.client.request({
'path': 'https://datastudio.googleapis.com/v1/assets:search?assetTypes=Report',
}).then(function(resp) {
console.log(resp);
});
}
Some settings:
but I got the same error when I filled in my gmail account/password:
And then I figured out from the doc:
Note: The Data Studio API is currently only available to G Suite and Cloud Identity domains.
it seems that I have to get a domain to use the GDS apis, and localhost does not work? am I right?
No, the reference to GSuite and Cloud Identity domains here is a reference to the domain/organization a user belongs to. In order to do the last step [1] in the DataStudio documentation, you need a G Suite admin to allow your application to request the datastudio scope for all users in that domain. That step is required. This API is only available to be used by GSuite users.
[1] https://developers.google.com/datastudio/api#authorize_oauth_client