Hi Dhanya,
Thanks for your reply.
Yes, I had done this last year and already have the OAuth tokens from
another account. But this is a new project and wanted new tokens.
Can you please confirm which lines to comment out - before doing your three
steps:
~~~
def setup_oauth2()
adwords = AdwordsApi::Api.new
token = adwords.authorize() do |auth_url|
puts "Hit Auth error, please navigate to URL:\n\t%s" % auth_url
print 'log in and type the verification code: '
verification_code = gets.chomp
verification_code
end
if token
print "\nWould you like to update your adwords_api.yml to save " +
"OAuth2 credentials? (y/N): "
response = gets.chomp
if ('y'.casecmp(response) == 0) or ('yes'.casecmp(response) == 0)
adwords.save_oauth2_token(token)
puts 'OAuth2 token is now saved to ~/adwords_api.yml and will be ' +
'automatically used by the library.'
end
end
end
~~~
Thanks
Arjun
On Friday, 9 February 2018 00:53:22 UTC+5:30, Dhanya Sundararaju (AdWords
API Team) wrote:
>
> Hi Arjun,
>
> In your adwords_api.yml
> <https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/adwords_api.yml>
> file, if you already have the OAuth tokens (access and refresh), the
> system will not ask you to reauthorize. Looks like that is happening in
> your case. To confirm this, you can comment the tokens in the
> adwords_api.yml
> <https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/adwords_api.yml>
> file
> and run the samples. For this, you will need to perform the steps in the
> order as below:
>
> 1. Run $ruby setup_oauth2.rb
> <https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/examples/v201710/misc/setup_oauth2.rb>
>
> You will get:
> "Hit Auth error, please navigate to URL:
>
> https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=****-***.apps.googleusercontent.com&redirect_uri=****&response_type=code&scope=https://www.googleapis.com/auth/adwords
>
> <https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=312235556420-sft57st2ee4dg173ghibg3fidllsr9a0.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/adwords>
> "
>
> 2. Navigate to the above URL in a private browser session or an incognito
> window. Log in with the same Google account you use to access AdWords.
> Click Allow on the OAuth2 consent screen. An authorization code will be
> shown to you. Copy and paste the verification code into the command line
> where you're running the setup_oauth2.rb example and press enter.
> You will get:
> "Would you like to update your adwords_api.yml to save OAuth2 credentials?
> (y/N):
>
> 3.Type 'y' and press enter.
> You will get :
> "OAuth2 token is now saved to ~/adwords_api.yml and will be automatically
> used by the library."
>
> This will take care of updating the adwords_api.yml
> <https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/adwords_api.yml>
> file.
> Please let me know if you have further questions.
>
> Regards,
> Dhanya, 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/d3a5098f-f2e2-47eb-8364-bd50f44b779f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.