Comments (5)
I solved that by using gem below.
https://github.com/carnesmedia/google-oauth2-installed
but I choose "Installed application", so it's may not correct way for your
case.
2015-06-04 23:49 GMT+09:00 Alok Swain [email protected]:
Hi,
I am using the Signet gem to get OAuth2 access token for a service
account. We are using Garb to fetch data from GA and display more logically
for our consumers.I tried the following
Garb::Session.access_token = access_token
Garb::Management::Profile.all
and I encountered the following error:NoMethodError: undefined method
'get' for #<String:0xcd585ac> from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/request/data.rb:94:in
oauth_user_request'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/request/data.rb:41:insend_request' from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/feed.rb:21:in
response'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/feed.rb:13:inparsed_response' from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/feed.rb:17:in
entries'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/garb-0.9.8/lib/garb/management/profile.rb:14:inall' from (irb):16 from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands/console.rb:47:in
start'
from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands/console.rb:8:instart' from /home/alok/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.19/lib/rails/commands.rb:41:in
<top (required)>'
from script/rails:6:inrequire' from script/rails:6:in
I think I am using it in a wrong way, I checked the docs and did not find
anything related to fetching data by Authenticating by service accounts. I
have verified from Google API playground the the access token I used is
valid. Can you guide me as to what am I doing wrong ? Is it possible to do
this via Garb (as I am not using Single User Login anymore as we need
server to server interactions and using Service accounts is the only way.Thanks,
Alok—
Reply to this email directly or view it on GitHub
#40.
┏◇─────────────────
┌─╂ 株式会社 先駈
■━┛ 代表取締役
│ 面川 泰明
│ TEL 03-6271-6858 FAX 03-6850-7117
│ Mail : [email protected]
□────────────────────
from garb.
The problem is not with OAuth. When I use the access token obtained by using Signet, how do I use that access token in Garb to fetch data from GA ? I think the authentication process is already done as I have a valid Auth Token via Signet.
from garb.
I have the same problem as you @alokswain. Did you solve the issue?
from garb.
@alokswain is your access_token
an instance of OAuth2::Client
?
from garb.
@Sija - Thats what I misunderstood. It works when Garb::Session.access_token
is an instance of OAuth2::Client
instead of a valid access_token. Thanks for the followup. I am closing the issue as I have resolved the problem and pasting the code I used below so that it might help someone in future:
key = Google::APIClient::KeyUtils.load_from_pkcs12("<p12_key_path>", "<p12key pwd>")
client = Google::APIClient.new(application_name: 'Service account demo', application_version: '0.0.1')
service_account = Google::APIClient::JWTAsserter.new(@ga_service_account, 'https://www.googleapis.com/auth/analytics.readonly', key)
client.authorization = service_account.authorize
oauth_client = OAuth2::Client.new("", "", {
:authorize_url => 'https://accounts.google.com/o/oauth2/auth',
:token_url => 'https://accounts.google.com/o/oauth2/token'
})
token = OAuth2::AccessToken.new(oauth_client, client.authorization.access_token, expires_in: 1.hour)
Garb::Session.access_token = token
profile = Garb::Management::Profile.all
Edit: Seems this can be directly done using Signet
now (untested) and JWTAsserter
is deprecated. Please refer Signet gem docs for more details on how to fetch the access token directly using Signet gem.
from garb.
Related Issues (20)
- Why don't you push on rubygems HOT 2
- Sample Application HOT 1
- Garb returns duplicate values HOT 2
- Contributors and link to Legato HOT 6
- unexpected json version errors HOT 2
- Please make this Gem available on RubyGems. HOT 13
- Multiple filters using OR HOT 1
- Unable to handle account without profiles HOT 1
- Unable to get access_token when using garb HOT 2
- Unable to authenticate from Travis HOT 1
- Unable to get profile. HOT 1
- Unable to get all profiles
- undefined method `token' for HOT 1
- Unable to Login with Single User - Garb::AuthenticationRequest::AuthError HOT 2
- Garb::ClientError: There was an internal error. HOT 1
- Are results fetched via Garb sampled
- After the OAuth 1.o shutdown on April 20, 2015 the Garb authentication is not working HOT 1
- Unable to filter using metrics operator such as >,>=, < and <=
- Dependabot can't resolve your Ruby dependency files HOT 1
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 garb.