Hi,
Can I check whether the logged-in user associated AdWords accounts for avoiding AuthenticationError.NOT_ADS_USER?
I'm using the following java library version.
* "com.google.api-ads" % "ads-lib" % 4.1.0,
* "com.google.api-ads" % "adwords-axis" % 4.1.0,
My code snippet is here(Scala).
I would like to check if the user associated AdWords accounts before (1) invoking CustomerServiceInterface#getCustomers may throw com.google.api.ads.adwords.axis.v201806.cm.ApiException with AuthenticationError.NOT_ADS_USER.
import com.google.api.ads.adwords.axis.factory.AdWordsServices
import com.google.api.ads.adwords.axis.v201806.mcm.CustomerServiceInterface
import com.google.api.ads.adwords.lib.client.AdWordsSession
import com.google.api.ads.common.lib.auth.OfflineCredentials
import com.google.api.ads.common.lib.auth.OfflineCredentials.Api
val credential = new OfflineCredentials.Builder()
.forApi(Api.ADWORDS)
.withRefreshToken(refreshToken)
.withClientSecrets(<from config>, <from config>)
.build()
.generateCredential()
)
val session =
new AdWordsSession.Builder()
.withOAuth2Credential(credential)
.withDeveloperToken(<from config>)
.build()
val customerService = AdWordsServices.getInstance().get(session, classOf[CustomerServiceInterface])
// (1)
customerService.getCustomers
Thanks,
Yoshimasa