使用Google Provisioning API创建帐户

时间:2013-06-27 10:18:47

标签: google-provisioning-api

我正在尝试使用来自转销商帐户的Google Provisioning API创建帐户。我们说经销商帐户是:reseller@reseller.com。在此之前,我已经从Google Reseller API订阅了域名“domain.com”。

基于这个链接(https://developers.google.com/google-apps/provisioning/#creating_a_user_for_a_domain),我创建了这样的脚本:

package gapps;


import com.google.gdata.data.*;
import com.google.gdata.client.*;
import com.google.gdata.data.appsforyourdomain.AppsForYourDomainException;
import com.google.gdata.data.appsforyourdomain.generic.GenericEntry;
import com.google.gdata.util.*;

import java.net.*;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level`enter code here`;
import java.util.logging.Logger;
import sample.appsforyourdomain.labs.provisioning.ProvisioningApiMultiDomainSampleClient;
import sample.appsforyourdomain.labs.provisioning.ProvisioningApiMultiDomainSampleClient.UserProperty;


public class Gapps {



    public static void main(String[] args) {
        try {

            Map<UserProperty, String> map = new HashMap<UserProperty, String>() ;
            map.put(ProvisioningApiMultiDomainSampleClient.UserProperty.ADMIN ,"isAdmin");

            GenericEntry genericEntry = new GenericEntry();
            ProvisioningApiMultiDomainSampleClient provisioningApiMultiDomainSampleClient = new ProvisioningApiMultiDomainSampleClient("reseller@reseller.com", "*******", "domain.com", "sample-api");
            genericEntry = provisioningApiMultiDomainSampleClient.createUser("user", "*******", "fname", "lname", map);
            System.out.println(genericEntry.toString());

        } catch (AppsForYourDomainException ex) {
            Logger.getLogger(Gapps.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(Gapps.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Gapps.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ServiceException ex) {
            Logger.getLogger(Gapps.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

但是在尝试编译之后总是返回

  

您无权访问此API。

我被困在这里。有什么东西让我错过了吗?

1 个答案:

答案 0 :(得分:0)

是否为您的转销商域启用了API访问权限?

http://support.google.com/a/bin/answer.py?hl=en&answer=60757