它对我来说很好。请您尝试以下方法。
final PlatformSessionContext context = getPlatformContext(accesstoken,
accessstokensecret, realmID, dataSource);
PlatformClient client = new PlatformClient();
System.out.println("User's email " + client.getUserInfo(context).getEmail());
JavaDoc 参考 - http://developer-static.intuit.com/SDKDocs/QBV2Doc/ipp-java-devkit-2.0.10-SNAPSHOT-javadoc/
(com.intuit.platform.client.PlatformClient)
请让我知道它是否适合您。
import com.intuit.platform.client.PlatformClient;
import com.intuit.platform.client.PlatformServiceType;
import com.intuit.platform.client.PlatformSessionContext;
import com.intuit.platform.client.security.OAuthCredentials;
public class Test {
String accesstoken = "keys ****";
String accessstokensecret = "keys ****";
String realmID = "*********";
String dataSource = "QBD";
String appToken = "keys ****";
String oauth_consumer_key = "keys ****";
String oauth_consumer_secret = "keys ****";
Test(){
final PlatformSessionContext context = getPlatformContext(accesstoken,
accessstokensecret, realmID, dataSource);
System.out.println(context);
PlatformClient client = new PlatformClient();
System.out.println("User's email " + client.getUserInfo(context).getEmail());
}
public PlatformSessionContext getPlatformContext(final String accessToken,
final String accessTokenSecret, final String realmID,
final String dataSource) {
PlatformServiceType serviceType;
if (dataSource.equalsIgnoreCase("QBO")) {
serviceType = PlatformServiceType.QBO;
} else {
serviceType = PlatformServiceType.QBD;
}
final OAuthCredentials oauthcredentials = new OAuthCredentials(
oauth_consumer_key, oauth_consumer_secret,
accessToken, accessTokenSecret);
final PlatformSessionContext context = new PlatformSessionContext(
oauthcredentials, appToken, serviceType, realmID);
return context;
}
public static void main(String args[]){
Test test = new Test();
}
}
谢谢