Here 
<https://developers.google.com/adwords/api/docs/guides/authentication#multithreaded_apps>
 its 
mentioned, 

"The client libraries make sharing a credential across threads 
straightforward. Each client library has a session (or user) object with a 
credential that it reuses throughout its lifetime. To share the credential 
across threads, simply construct each session using the same credential. In 
all client libraries, the credential is a thread-safe object that refreshes 
itself synchronously when its access token expires."

My use case - Using this 
<https://developers.google.com/adwords/api/docs/samples/java/remarketing#add-crm-based-user-list>
 I 
am uploading emails/phone numbers to my customers adWords account.
I am using the following code to generate credentials 

Credential oAuth2Credential = new OfflineCredentials.Builder()
 .forApi(OfflineCredentials.Api.ADWORDS)
 .withClientSecrets(GOOGLE_ADWORDS_CLIENT_ID, GOOGLE_ADWORDS_CLIENT_SECRET)
 .withRefreshToken(refreshToken).build().generateCredential();

// Construct an AdWordsSession.
AdWordsSession session = new 
AdWordsSession.Builder().withClientCustomerId(clientCustomerId)
 .withDeveloperToken(GOOGLE_ADWORDS_DEVELOPER_TOKEN)
 .withOAuth2Credential(oAuth2Credential)
 .withUserAgent("test_user").build();

AdWordsServicesInterface adWordsServices = AdWordsServices.getInstance();
userListService = adWordsServices.get(session, 
AdwordsUserListServiceInterface.class);

I am batching 20k emails from my end and for every 20k emails I am firing the 
above code. But according to the above quote

(which is a bit confusing), this is not a best practice? If I understand the 
above paragraph correctly, do you guys suggest that the 

oAuth2Credential variable be made into Thread-Safe object and then it should be 
used to create session persistently? 


Or If I am mistaken can you guys please help me in explaining this?


Thanks

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/4af19522-7fc9-4dae-baaa-68f5cdff8fff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... Prashant Pandey
    • ... 'Peter Oliquino (AdWords API Team)' via AdWords API and Google Ads API Forum
      • ... Prashant Pandey

Reply via email to