我最近开始使用 Bing Ads api 来管理我的广告和活动,但我在验证用户(不是 oauth 验证)时遇到了问题。
我通过以下方式使用 oauth 对我的用户进行了身份验证
private String devToken = "ZZZZZ";
private String clientId = "AAA0BBB-XXXX-AAAAA";
protected static String UserName = "a.v@h.c";
protected static String Password = "********";
// To get the initial access and refresh tokens you must call requestAccessAndRefreshTokens with the authorization redirection URL.
OAuthTokens tokens = oAuthDesktopMobileAuthCodeGrant.requestAccessAndRefreshTokens(url);
System.out.println("Access token: " + tokens.getAccessToken());
System.out.println("Refresh token: " + tokens.getRefreshToken());
authorizationData = new AuthorizationData();
authorizationData.setDeveloperToken(getDevToken());
authorizationData.setAuthentication(oAuthDesktopMobileAuthCodeGrant);
这可以很好地验证我的用户,因为我可以将ICustomerManagementService.class
就好用于帐户相关信息
customerServiceClient = new ServiceClient<>(authorizationData, ICustomerManagementService.class);
ArrayOfAccount accounts = searchAccountsByUserId(user.getId());
以上工作完美。但是当我尝试用ICampaignManagementService.class
下面的方法做同样的事情时
campaignServiceClient = new ServiceClient<>(authorizationData, ICampaignManagementService.class);
GetAdsByAdGroupIdRequest cReq = new GetAdsByAdGroupIdRequest();
cReq.setAdGroupId(1234567890L);
campaignServiceClient.getService().getAdsByAdGroupId(cReq);
我收到错误代码 106,表示用户未获得授权。
The user does not represent a authorized developer.
106
在这方面有什么帮助吗?