ruby setup_oauth2.rb error

31 views
Skip to first unread message

Arjun Rajkumar

unread,
Feb 8, 2018, 7:22:58 AM2/8/18
to AdWords API Forum
Hi, 

I am installing the adwords api via this official doc:
https://github.com/googleads/google-api-ads-ruby/wiki/API-access-using-own-credentials-(installed-application-flow)

In step 2, when I run 'setup_oauth2.rb' I am getting this response :
'OAuth2 token is now saved to ~/adwords_api.yml and will be automatically used by the library.'



"
  1. The example will prompt you to visit a URL where you will need to allow the OAuth2 credentials to access your AdWords account on your behalf. Navigate to the 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."
"

I'm not getting that. Any idea how to fix this. 

THanks

Arjun

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 8, 2018, 2:23:22 PM2/8/18
to AdWords API Forum
Hi Arjun,

In your 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 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 
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"

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 file. Please let me know if you have further questions.

Regards,
Dhanya, AdWords API Team
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages