Hi,
Just looking to learn more about the Adwords API, and thought i'll test the adwords_on_rails example on my local system.
The example always starts by authenticating a user if a user is not signed in.
# Checks if we have a valid credentials.
def authenticate()
token = session[:token]
redirect_to login_prompt_path if token.nil?
return !token.nil?
end
Over here as the session[:token] is nil - it redirects to the login_prompt_path
This is the code for that
def prompt()
api = get_adwords_api()
if session[:token]
redirect_to home_index_path
else
begin
token = api.authorize({:oauth2_callback => login_callback_url})
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
@login_url = e.oauth_url
end
end
end
Over here it authorises the api and gets the token details.
From my app - these are the details.
token:
pry(#<LoginController>)> token
=> {:access_token=>"ya29.GlwdBFmXLFG6N4LZcXYZXXYZXYZsI3w2TO7S2AT8jxg2H5M9fZK8w",
:refresh_token=>"1/MRi81Wp0D0XYZXXYZXYZsSsioOgHxas",
:issued_at=>2017-03-29 09:11:29 +0530,
:expires_in=>3600,
:id_token=>nil}
[2] pry(#<LoginController>)> @login_url
=> nil
Then in the view for login_prompt_path - it says this.
<p>Please authorize with a google account first:</p>
<p><a href="<%= @login_url %>">Proceed</a></p>
I understand that I need to click on Proceed so that I can select an Adwords account for this example.
However, my @login_url is always nil - so the clicking on Proceed - does nothing.
Can someone please help me solve this. I seem to be doing something wrong - but have copied this code from the example.
Would really help to get some answers to this. Thanks for your time.
Arjun