0
我正嘗試使用Google Provisioning API從經銷商帳戶創建帳戶。讓我們說經銷商帳戶是:[email protected]。在此之前,我已經從Google Reseller API訂閱了域名「domain.com」。使用Google Provisioning API創建帳戶
基於此鏈接(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("[email protected]", "*******", "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。
我被困在這裏。有什麼我錯過了..?
嗨,我alelady解決了這個問題。這似乎是因爲我使用參數圖。當我刪除這個參數時,我的程序正常工作。 – xikyu46