Thanks Vincent for information.
We want to create refresh tokens for individual accounts because our vendor
(third party campaign manger who manages our accounts) also managing other
company account in same hierarchy,he dont want to give root manager account
refresh token as it will expose other company accounts too which he is
managing.
Since we are going to use refresh token per client account. I am going to
authenticate each refresh token in application startup it self and keep all
accesstokens in a HashMap to use later point.
I have seen accessToken expire time is one hour. Java Adwords client
libraries will automatically refresh access tokens once it expires right.
Below is the code I am going to use and My HashMap will be like map(
clientId,AdWordsSession );
public AdWordsSession generateAdwordsSession(final Properties prop,final
String clientId) {
String dpTokenUrl = (String) prop.getProperty(DP_TOKEN_URL);
String refreshToken = refreshTokenMap.get(clientId);
// Generate a refreshable OAuth2 credential.
Credential oAuth2Credential;
try {
oAuth2Credential = new
OfflineCredentials.Builder().forApi(Api.ADWORDS).withTokenUrlServer(dpTokenUrl).withRefreshToken(refreshToken).fromFile().build()
.generateCredential();
// Construct an AdWordsSession.
return new
AdWordsSession.Builder().fromFile().withOAuth2Credential(oAuth2Credential).build();
} catch (OAuthException | ValidationException | ConfigurationLoadException
e) {
LOGGER.error("Error in getting AdwordsSession with given credentials", e);
return null;
}
}
Can you please let me know whether above approach works or not ?
Thanks!
Hari.
On Wednesday, November 8, 2017 at 2:29:01 PM UTC+5:30, Vincent Racaza
(AdWords API Team) wrote:
>
> Hi Hari,
>
> Please see answers below to your questions.
>
> 1) Can I create campaigns under root manager account directly with out
> child client account. If yes can you please point me to a
> documentation/guide so that i can create campaigns under direct root
> manager account.
>
> Campaigns cannot be created in a manager account. It can only be created
> in a client account. This is true for both AdWords UI and API. You can
> check this example
> <https://developers.google.com/adwords/api/docs/samples/java/basic-operations#add-campaigns>
> (in
> Java) on how to create campaigns.
>
> For your questions 2 and 3, kindly refer to my answer below.
>
> Refresh token is not campaign based, it is user based or email address
> based. You can check these users in your *AdWords UI -> Account settings*.
> For example, if you have 2 users (e.g. [email protected] <javascript:>,
> [email protected] <javascript:>) in your client account, then you can
> generate OAuth2 credentials (with client ID, client secret, refresh token)
> to these two users. The user a@example will have a unique refresh token and
> [email protected] <javascript:> will have a different unique refresh
> token. The idea here is that OAuth2 credential is associated to an *email
> address of a user* which is under your client/manager account, and not on
> a campaign or the client account itself.
>
> You can check this guide
> <https://developers.google.com/adwords/api/docs/guides/authentication> on
> how to authenticate in the AdWords API including the generation of refresh
> token (see this section
> <https://developers.google.com/adwords/api/docs/guides/authentication#configure_and_use_a_client_library>
> ).
>
> Could you confirm on why do you want to generate separate refresh tokens
> to your campaigns or to your client accounts? If you want to access
> multiple client accounts under an MCC, then you can select a user from that
> MCC that has administrative/standard access, and generate the OAuth
> credential for that user. This way, your credential can access the MCC and
> all sub MCCs and client accounts under it.
>
> Let me know if you have further clarifications.
>
> Thanks,
> Vincent
> AdWords API Team
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords 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 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/0ffcfc15-a199-47fa-8206-5c0fd40b35ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.