Hello Clement,

You need to get user grant before you can access his account. Please take a 
look at this Ruby application for an example:

  
http://code.google.com/p/google-api-ads-ruby/source/browse/adwords_api/examples/adwords_on_rails/


-Danial, AdWords API Team.


On Thursday, July 4, 2013 2:46:37 AM UTC+4, Clement Miao wrote:
>
> I am currently trying to use the API's ruby library to pull average cpc 
> data for certain keywords for internal research and just want to output it 
> in command line. 
>
> I have applied for a developer token for the API, and am currently testing 
> using a test account. 
>
> The beginning of my method looks like:
>
> require 'adwords_api'
>     #google API setup
>     adwords = AdwordsApi::Api.new
>
>     #Specify to use the TargetingIdeaService
>     targeting_srv = adwords.service(:TargetingIdeaService, :v201302)
>     #construct selector
>     selector = {:idea_type => 'KEYWORD',
>                 :request_type => 'STATS',
>                 :requested_attribute_types => ['AVERAGE_CPC'],
>                 :search_parameters => [
>                     {
>                         :xsi_type => 'RelatedToQuerySearchParameter',
>                         :queries => [keyword_text]
>                     }
>                 ],
>                 :paging => {
>                     :start_index => 0,
>                     :number_results => 1
>                 }
>     }  
>
>
>
>
>
>
> Also, my configuration file adwords_api.yml is of the form:
>
> :authentification:
>     :method: OAuth2
> :oauth2_client_id: 'private client id'
> :oauth2_client_secret: 'private client secret'
> :developer_token: 'developer token' #not yet approved but for testing 
> purposes
> :client_customer_id: 'customer id'
>
> However when I run my method, I get the following error message: 
> AdsCommon::Errors::OAuth2VerificationRequired: 
> AdsCommon::Errors::OAuth2VerificationRequired
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/auth/oauth2_handler.rb:210:in
>  
> `generate_access_token'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/auth/oauth2_handler.rb:156:in
>  
> `create_token'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/auth/base_handler.rb:50:in
>  
> `get_token'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/auth/oauth2_handler.rb:82:in
>  
> `get_token'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/auth/oauth2_handler.rb:75:in
>  
> `auth_string'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/savon_headers/oauth_header_handler.rb:45:in
>  
> `generate_headers'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/savon_headers/base_header_handler.rb:75:in
>  
> `prepare_request'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/savon_service.rb:103:in
>  
> `block in execute_soap_request'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/savon-1.2.0/lib/savon/client.rb:129:in
>  
> `yield_objects'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/savon-1.2.0/lib/savon/client.rb:122:in
>  
> `process'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/savon-1.2.0/lib/savon/client.rb:84:in
>  
> `block in request'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/savon-1.2.0/lib/savon/soap/request_builder.rb:56:in
>  
> `call'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/savon-1.2.0/lib/savon/soap/request_builder.rb:56:in
>  
> `request'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/savon-1.2.0/lib/savon/client.rb:86:in
>  
> `request'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/savon_service.rb:101:in
>  
> `execute_soap_request'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-ads-common-0.9.2/lib/ads_common/savon_service.rb:81:in
>  
> `execute_action'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/google-adwords-api-0.9.2/lib/adwords_api/v201302/targeting_idea_service.rb:21:in
>  
> `get'
> from /Users/miao/rails/RedisLead/app/models/lead.rb:32:in `cpc'
> from (irb):12
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in
>  
> `start'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in
>  
> `start'
> from 
> /Users/miao/.rvm/gems/ruby-1.9.3-p392@global/gems/railties-3.2.13/lib/rails/commands.rb:41:in
>  
> `<top (required)>'
> from script/rails:6:in `require'
> from script/rails:6:in `<main>
>
>
> It seems like it is a problem with the OAuth2 verification, but I am 
> confused as to what that means. I looked at this 
> page<https://code.google.com/p/google-api-ads-ruby/wiki/OAuth2>but I was 
> unsure as to how to implement it. 
>
> Sorry for the amateur question, but this is really bugging me! 
>
>
>
>
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.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 [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].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to