AdwordsSession Managment

66 views
Skip to first unread message

Jonathan

unread,
Jan 23, 2015, 12:41:09 PM1/23/15
to adwor...@googlegroups.com
Hey everybody

I have a question about the AdwordsSession object and the AdWordsServices object and whats the best way to use these objects

We have an MCC account with a few accounts.

As for my understanding i will need to create a different instance of AdwordsSession for each of the accounts. Can i keep these instance alive for as much time as i want?
For instance if i create an AdwordsSession for account A and then keep it referenced in a Map with a key of the account, can i just pull the same object later on (week or month or year)? i guess there would be some timeout?

I have also read that i should create a different instance of the AdWordsServices object for each account. Why is that?

Should the com.google.api.client.auth.oauth2.Credential object be created only once and used by all of the different AdWordsSession.Builder() ? Or creating one Credential for each session?

Should this Credential object instance also be saved in memory for later use or should be created each time it is needed? 
This is the object that refreshes automatically right? i would love to understand how that works and if i should do anything to make sure that everything will work as expected?


Sorry for asking so many questions at once - thanks for any help!
Cheers


Josh Radcliff (AdWords API Team)

unread,
Jan 23, 2015, 4:31:53 PM1/23/15
to adwor...@googlegroups.com
Hi,

The Java client library has a page on Thread Safety that answers many of the questions below.

Regarding the AdWordsSession, you could either keep a separate instance per account or reuse the same instance and call setClientCustomerId(...) between calls. Note, however, that instances of this class are not thread-safe.

If you still have questions after reading through the page linked above, let me know.

Thanks,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages