Comments (1)
Updated first step -- use the oauth2_state
parameter when initializing AdManagerApi::Api
. First step code below:
class GamAccessRequest
CLIENT_ID = ENV['GAM_CLIENT_ID']
SECRET_ID = ENV['GAM_SECRET_ID']
APP_URL = some way to figure out 'https://www.whatever.com'
def initialize(some_id: nil)
@some_id = some_id
end
def valid?
CLIENT_ID.present? && @some_id.present?
end
def params
{
method: 'OAuth2',
oauth2_client_id: CLIENT_ID,
oauth2_client_secret: SECRET_ID,
oauth2_state: encoded_state,
application_name: 'Google Ad Manager Client',
# https://stackoverflow.com/a/10857806
oauth2_prompt: 'consent',
oauth2_access_type: 'offline'
}
end
def ad_manager
AdManagerApi::Api.new({
:authentication => params,
:service => {
:environment => 'PRODUCTION'
}
})
end
def callback_url
APP_URL + '/partners/google/auths/grant'
end
def wonky_url_acquisition
begin
ad_manager.authorize(oauth2_callback: callback_url)
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
e.oauth_url.to_s
end
end
def url
@url ||= wonky_url_acquisition
if @url.nil?
Sentry.capture_message("Expecting a URL here but got none. params: #{params.to_json}")
end
@url
end
def state_data
{network_id: @network_id}
end
def encoded_state
encryptor = ActiveSupport::MessageEncryptor.new(SMALL_SECRET_KEY)
secret = state_data.to_json
encryptor.encrypt_and_sign(secret)
end
end
from google-api-ads-ruby.
Related Issues (20)
- 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
- 2.4.0 uses v202305 API version of Google Ad Manager, not v202308 HOT 4
- Build a statement with `importDateTime` query
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.