Comments (5)
You should try to use the authorize method on api instead.
Try @api.authorize({:oauth2_token => access_token})
On Sun, Dec 22, 2013 at 3:36 AM, Joan.R [email protected] wrote:
I have the following situation:
First time the User gives my application permition to access its Adwords
account, I store the following in my DB:access_token, refresh_token, expires_in, issued_at
Later, when I want to do an API call, I get those values from the current
user, and do the following:@api = AdwordsApi::Api.new(config_filename)
token = {:access_token => current_user.access_token, :refresh_token =>
current_user.refresh_token, :expires_in => current_user.adwords_expires_in,
:issued_at => current_user.adwords_issued_at, :id_token => nil }
credentials = @api.credential_handler()
credentials.set_credential(:oauth2_token, token)
credentials.set_credential(:client_customer_id, selected_account)However, it seems that when that access_token has expired, I get a OAUTH
INVALID TOKEN error.Isn't this the correct way of doing offline access? What am I missing
here? I am also guessing that if I do it this way, I would never be
updating the access_token with the new access_token that I got from the
refresh_token, so I am wondering what would be the correct way to do so?PD: It would be nice if you could tell the people that manage the API
Adwords forum to check for new users and accept/approval their messages ;)—
Reply to this email directly or view it on GitHubhttps://github.com//issues/13
.
from google-api-ads-ruby.
If I do:
@api.authorize({:oauth2_token => access_token})
Where access_token is the Hash with token and refresh token, I keep getting OAUTH_TOKEN_INVALID when trying to hit the API. Actually this @api.authorize({:oauth2_token => access_token})
returns the same Hash that I currently have, so I guess it's not working as expected (is not getting a new token from the endpoint).
from google-api-ads-ruby.
Try modifying the hash and setting the issued_at to yesterday.
On Mon, Dec 23, 2013 at 3:28 AM, Joan.R [email protected] wrote:
If I do:
@api.authorize({:oauth2_token => access_token})
Where access_token is the Hash with token and refresh token, I keep
getting OAUTH_TOKEN_INVALID when trying to hit the API. Actually this @api.authorize({:oauth2_token
=> access_token}) returns the same Hash that I currently have, so I guess
it's not working as expected.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-31091053
.
from google-api-ads-ruby.
TigerWolf, thanks for your suggestion. Have you tried this with the Rails example provided in the library?
Because I keep getting the same thing. When I do:
returned_token = @api.authorize(:oauth2_token => token, :client_customer_id => selected_account)
Where token is:
{:access_token=>"xxxxxxxxxxxxxx", :refresh_token=>"xxxxxxxxxxxxxxxxxx", :issued_at=>Sun, 22 Dec 2013 23:29:33 UTC +00:00, :expires_in=>3600, :id_token=>nil}
If I do @api.inspect, right after the authorize call I get:
#<AdwordsApi::Api:0xbc2e074 @wrappers={}, @config=#<AdsCommon::Config:0xbc2e04c @config={:authentication=>{:method=>:OAUTH2, :oauth2_client_id=>"xxxxx", :oauth2_client_secret=>"xxxxx", :developer_token=>"xxxxx", :user_agent=>"rails", :oauth2_token=>{:access_token=>"xxxxx", :refresh_token=>"xxxxx", :issued_at=>Sun, 22 Dec 2013 23:29:33 UTC +00:00, :expires_in=>3600, :id_token=>nil}, :client_customer_id=>"121212"}, :service=>{:environment=>:PRODUCTION}, :connection=>{:enable_gzip=>false}, :library=>{:log_level=>"INFO", :logger=>#<Logger:0xbc3692c @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0xbc36954 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0xbc36a1c @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0xbc36a30 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0xbc37034>>>>}}>, @logger=#<Logger:0xbc3692c @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0xbc36954 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0xbc36a1c @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0xbc36a30 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0xbc37034>>>>, @credential_handler=#<AdwordsApi::CredentialHandler:0xbc37200 @config=#<AdsCommon::Config:0xbc2e04c @config={:authentication=>{:method=>:OAUTH2, :oauth2_client_id=>"xxxxx", :oauth2_client_secret=>"xxxxxxxP", :developer_token=>"xxxxxxxxxxxxxxxx", :user_agent=>"rails", :oauth2_token=>{:access_token=>"xxxxxxxxxxxxxx", :refresh_token=>"xxxxxxxxxxx", :issued_at=>Sun, 22 Dec 2013 23:29:33 UTC +00:00, :expires_in=>3600, :id_token=>nil}, :client_customer_id=>"121212"}
But when trying to use the @api object to do an API call, I keep getting:
Exception occurred: AdwordsApi::V201309::CampaignService::ApiException
[AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'']
I should add that I have in the config file oauth2_access_type: 'offline'
from google-api-ads-ruby.
Closing. I was having a misspelling in one of my Models that was avoiding refreshing the token.
from google-api-ads-ruby.
Related Issues (20)
- Support for incremental oauth
- ReportableType is unexpected when creating CustomTargetingKey HOT 1
- Creating Callout Extensions in Adwords HOT 1
- Occurred error after entering verification code
- How to perform authentication client side? HOT 2
- Got "Unable to parse response body" from Ruby ad manager api HOT 3
- File permissions issue in google-dfp-api-1.11.0 and google-dfp-api-1.12.0 gems HOT 6
- `download_report_as_stream` ignores HTTP status code HOT 1
- GoogleAdsSavon::SOAP::InvalidResponseError Unable to parse response body HOT 2
- process GoogleAdsService.Search() never ends HOT 1
- Click Performance Report API endpoint failing with a Zlib buffer Error HOT 5
- Support Rails 6.1 HOT 5
- Will this library be sunset with Google AdWords API? HOT 1
- google-dfp-api gem 1.15.0 not compatible with Rails 5.2 HOT 1
- How to install google-adwords-api for version of Ruby lower than 2.2.2 HOT 1
- Default branch is now main
- My dreams officiall pakistan
- Out-Of-Band EOL
- Passing stateful information in initial authorization request? HOT 1
- 2.4.0 uses v202305 API version of Google Ad Manager, not v202308 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-api-ads-ruby.