Hi Jean,

I'm going to send this over to our PHP client library expert. Since your 
questions revolve around the details of that library, you may want to open 
an issue on Github <https://github.com/googleads/googleads-php-lib/issues> so 
we can track this under the library's issue tracker.

Thanks,
Josh, AdWords API Team

On Monday, January 8, 2018 at 12:34:36 AM UTC-5, Jean-Fabrice Rabaute wrote:
>
> Hi Vincent,
>
> Thank you for your answer.
> I have added more questions inline.
> For info, I'm using the public google adwords php library 
> <https://github.com/googleads/googleads-php-lib>.
>
> Le dimanche 7 janvier 2018 21:00:59 UTC-8, Vincent Racaza (AdWords API 
> Team) a écrit :
>>
>> Hi Jean,
>>
>> If you are using our client libraries, you don't need to manually set the 
>> access token in your request as the library itself is generating an access 
>> token in the background using your refresh token. 
>>
>
> What does "generating" means here? I've tried, and in my case, it means an 
> http request to get a new access token. It means that it's slow because 
> almost every query to the adwords api is from a newly instantiated 
> AdwordsSessionBuilder so there is no access token. So every time my web app 
> is getting a client call and instantiating the object, and querying adwords 
> api on behalft of the client, two synchronous calls will be done: one to 
> get a valid access token, one for the real query.
>
>
>  
>
>> If your access token is about to expire or has already expired, the 
>> client library will automatically generate a new access token using the 
>> refresh token.
>>
>> About setting or reusing the access token, this is already incorporated 
>> in the client libraries, and you don't need to do this manually. 
>>
>
> How can the library do this when it does not know anything about the 
> environment it's working on? When a system is distributed (having multiple 
> instances of the web app running on different machines and load-balanced), 
> how can the php library itself share and synchronize a common resource 
> between the instances?
>
> The Google Adwords doc is talking about this problem here: 
> https://developers.google.com/adwords/api/docs/guides/authentication#optimizing_oauth2_requests
>
> It seems pretty clear to me that it's the application responsibility to 
> cache/share/synchronize the token on a distributed app design.
>
> Am I missing something? If so, can you point me to the code in the adwords 
> php library which takes care of caching the access_token on distributed 
> environments?
>  
>
>> There is also no method currently that would manually set the access 
>> token in your request. If you want to reuse your access token for your 
>> separate requests, then you can use the refresh token instead as this is 
>> linked to your access token at a time.
>>
>
> Yes, that works, but it's means adding a preliminary http request every 
> time, which is not optimal.
>  
>
>>
>> Also, if you are not using our client libraries, you can refer to the 
>> generic OAuth2 guide 
>> <https://developers.google.com/identity/protocols/OAuth2>. The guide 
>> provides a step by step instructions on how to authenticate via the 
>> authentication type of your choice. For example, if you will be 
>> authenticating via the "Installed application" type 
>> <https://developers.google.com/identity/protocols/OAuth2InstalledApp>, 
>> it provides the whole steps on how to generate the refresh and access 
>> tokens and how to call an API method 
>> <https://developers.google.com/identity/protocols/OAuth2InstalledApp#callinganapi>
>>  via 
>> HTTP or CURL request.
>>
>> If you have further clarifications on this, I suggest that you create a 
>> new forum thread so we can better track your concern.
>>
>> Thanks,
>>
>
> 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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
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/b84cf109-a6fb-4e97-af69-90a31fcdb0b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • Re: ... Jean-Fabrice Rabaute
    • ... Jean-Fabrice Rabaute
      • ... 'Vincent Racaza (AdWords API Team)' via AdWords API Forum
        • ... Jean-Fabrice Rabaute
          • ... 'Josh Radcliff (AdWords API Team)' via AdWords API Forum
    • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API Forum
      • ... Jean-Fabrice Rabaute
        • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API Forum
          • ... Jean-Fabrice Rabaute
            • ... 'Thanet Knack Praneenararat (AdWords API Team)' via AdWords API Forum

Reply via email to