使用javascript客户端lib丢失了如何使用Google Admin Directory API

时间:2013-06-13 10:08:07

标签: google-admin-sdk

我将其包含在我的html5应用程序中(缩小版)

<script>
    function load() {
        gapi.client.setApiKey('API_KEY');
        gapi.auth.authorize({client_id: 'CLIENT_ID',
            scope: 'https://www.googleapis.com/auth/admin.directory.user https://www.googleapis.com/auth/admin.directory.user.readonly'
            }, function(){
            gapi.client.load('admin', 'directory_v1', function() {
              // Step 5: Assemble the API request
              console.log(gapi.client);
              var request = gapi.client.directory.users.list({
                customer: "my_customer"
              });
              // Step 6: Execute the API request
              request.execute(function(resp) {
                console.log('RESPONSE', resp);
              });
            });

        });
    }
</script>
<script src="https://apis.google.com/js/client.js?onload=load"></script>

我想访问我的google apps帐户中的目录 - 当我使用google api资源管理器执行此操作时,我可以获取我需要的所有信息,但是通过google api javascript客户端(我知道它仍然在beta)我从rpc:

返回错误

[{"error":{"code":404,"message":"Not Found","data":[{"domain":"global","reason":"notFound","message":"Not Found"},{"domain":"global","reason":"internalError","message":"Internal Error"}]},"id":"gapiRpc"}]

但是我知道我有正确的凭据/范围等,因为发现调用会让我回到这个结果:

{"methods":{"directory.chromeosdevices.get":{"id":"directory.chromeosdevices.get"},"directory.chromeosdevices.list":{"id":"directory.chromeosdevices.list"},"directory.chromeosdevices.patch":{"id":"directory.chromeosdevices.patch"},"directory.chromeosdevices.update":{"id":"directory.chromeosdevices.update"},"directory.groups.aliases.delete":{"id":"directory.groups.aliases.delete"},"directory.groups.aliases.insert":{"id":"directory.groups.aliases.insert"},"directory.groups.aliases.list":{"id":"directory.groups.aliases.list"},"directory.groups.delete":{"id":"directory.groups.delete"},"directory.groups.get":{"id":"directory.groups.get"},"directory.groups.insert":{"id":"directory.groups.insert"},"directory.groups.list":{"id":"directory.groups.list"},"directory.groups.patch":{"id":"directory.groups.patch"},"directory.groups.update":{"id":"directory.groups.update"},"directory.members.delete":{"id":"directory.members.delete"},"directory.members.get":{"id":"directory.members.get"},"directory.members.insert":{"id":"directory.members.insert"},"directory.members.list":{"id":"directory.members.list"},"directory.members.patch":{"id":"directory.members.patch"},"directory.members.update":{"id":"directory.members.update"},"directory.mobiledevices.action":{"id":"directory.mobiledevices.action"},"directory.mobiledevices.delete":{"id":"directory.mobiledevices.delete"},"directory.mobiledevices.get":{"id":"directory.mobiledevices.get"},"directory.mobiledevices.list":{"id":"directory.mobiledevices.list"},"directory.orgunits.delete":{"id":"directory.orgunits.delete"},"directory.orgunits.get":{"id":"directory.orgunits.get"},"directory.orgunits.insert":{"id":"directory.orgunits.insert"},"directory.orgunits.list":{"id":"directory.orgunits.list"},"directory.orgunits.patch":{"id":"directory.orgunits.patch"},"directory.orgunits.update":{"id":"directory.orgunits.update"},"directory.users.aliases.delete":{"id":"directory.users.aliases.delete"},"directory.users.aliases.insert":{"id":"directory.users.aliases.insert"},"directory.users.aliases.list":{"id":"directory.users.aliases.list"},"directory.users.delete":{"id":"directory.users.delete"},"directory.users.get":{"id":"directory.users.get"},"directory.users.insert":{"id":"directory.users.insert"},"directory.users.list":{"id":"directory.users.list"},"directory.users.makeAdmin":{"id":"directory.users.makeAdmin"},"directory.users.patch":{"id":"directory.users.patch"},"directory.users.photos.delete":{"id":"directory.users.photos.delete"},"directory.users.photos.get":{"id":"directory.users.photos.get"},"directory.users.photos.patch":{"id":"directory.users.photos.patch"},"directory.users.photos.update":{"id":"directory.users.photos.update"},"directory.users.undelete":{"id":"directory.users.undelete"},"directory.users.update":{"id":"directory.users.update"}}}

谁能告诉我我做错了什么?我无法看到我做错了什么,我发送了客户参数,并在gapi.client中的对象中使用了正确的函数,它被加载到gapi.client,因为我可以看到它我可以使用,返回时只会出错

0 个答案:

没有答案