Hi Rasmus,

You could use the OAuth playground to generate access token, but as you 
noticed, the access token expires in an hour. This is good for short demo 
purposes, but if you want a long-running process or an unattended cron job, 
this approach won't work. Plus, our servers will see your application as 
"OAuth Playground", since you are using its clientId to generate access 
token. If you want to identify your application as Gawr (and hence get your 
own rate limits, settings, etc.) then you should register your own client 
id and secret from Google Cloud console and then generate OAuth access / 
refresh token using those credentials.

OAuth2 is a bit more difficult to implement when compared to ClientLogin, 
but since it is an open standard, there are lots of libraries that 
implement the protocol for you. You could use one of those to do the OAuth2 
flow, and then use the access token to make AdWords API calls. A quick 
google search brought up this library: 
http://andreareginato.github.io/simple-oauth2/. 
It seems to support both the authorization flow and access token refresh 
flow.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

On Thursday, January 2, 2014 10:11:31 PM UTC-5, Rasmus Ladekjær Pedersen 
wrote:
>
> Thank you for your interest. I have added the possibility to use a 
> --customerId flag to specify a client customer id other than the one in 
> config. Good idea. Thanks. I have also corrected a few bugs.
>
> The OAuth 2.0 part is however rather hard on me. Gawr is now using OAuth 
> 2.0 in a preliminary way. The users obtain an access token via 
> https://developers.google.com/oauthplayground and the program will work 
> for an hour. Obviously, the refresh token should be used.
>
> My answer is why are you taking about 
> https://cloud.google.com/console#/project, clientId and clientSecret. 
> What am I missing?
>
> I would be glad to hear anything from your or your colleague.
>
>
>
> On Tuesday, December 17, 2013 3:01:12 PM UTC+1, Anash P. Oommen (AdWords 
> API Team) wrote:
>>
>> Hi Rasmus,
>>
>> That's a pretty useful script. I've heard a few users asking for one, but 
>> it's the first time I'm seeing a user write one and contribute to the 
>> community. Thanks a lot! One of my colleagues was experimenting with 
>> AdWords API on Node.js, I'll ask him to take a look and reach out to you.
>>
>> I have a couple of suggestions: 
>>
>>
>>    - It is useful to have a --customerId flag that reads from config if 
>>    one is not provided on the command line. That way, one could switch 
>>    customer ids on command line w/o changing the config.
>>    - You should try to use OAuth2 as authentication mechanism, since 
>>    ClientLogin protocol is deprecated and will go away in the next 6 months. 
>>    The rough steps to generate one using OAuth 2.0 Playground would be as 
>>    follows (I apologize, I don't have a handy guide to point you to in our 
>>    documentation site):
>>       - Visit Google Cloud Console. 
>>       https://cloud.google.com/console#/project
>>       - Create a new project, then register a *web* application. Provide 
>>       https://developers.google.com/oauthplayground a callback url. This 
>>       will give you an OAuth2 *clientId *and *clientSecret*.
>>       - Visit https://developers.google.com/oauthplayground/. Click the 
>>       OAuth2.0 configuration button on the top right corner, and check "Use 
>> your 
>>       own OAuth credentials". Add the OAuth2 clientId and clientSecret from 
>> the 
>>       Google cloud console on this page, and Save.
>>       - Do the OAuth2 flow on the main application, for scope = 
>> *https://adwords.google.com/api/adwords 
>>       <https://adwords.google.com/api/adwords>. *At the end of the flow, 
>>       the page will print out a refresh token and an access token.
>>       - In your application, you need to send the authorization header 
>>       as *Authorization: Bearer access_token* instead of Authorization 
>>       GoogleLogin...
>>       - Access tokens will expire in an hour, but you could use the 
>>       refresh token to get a new access token. The raw http message for the 
>> same 
>>       is available here: 
>>       https://developers.google.com/accounts/docs/OAuth2WebServer#refresh
>>    
>> Cheers,
>> Anash P. Oommen,
>> AdWords API Advisor.
>>
>> On Monday, December 16, 2013 6:45:06 PM UTC-5, Rasmus Ladekjær Pedersen 
>> wrote:
>>>
>>> I wrote this little node.js script to retrieve report from Google 
>>> AdWords. When I myself was new to the API I would really have liked a 
>>> simple script like that, and that is why I later wrote it and now post it 
>>> here.
>>>
>>> https://github.com/ladekjaer/node-gawr
>>>
>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to