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
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/cd9e5c1d-ee3c-424f-812d-e96613abbb5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.