-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to fetch the profiles from Google Analytics using Server to server OAuth2 #40
Comments
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 2015-06-04 23:49 GMT+09:00 Alok Swain notifications@github.com:
┏◇───────────────── |
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. |
I have the same problem as you @alokswain. Did you solve the issue? |
@alokswain is your |
@Sija - Thats what I misunderstood. It works when 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 |
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. We have updated Garb gem version 0.9.8.
I tried the following
Garb::Session.access_token = access_token
Garb::Management::Profile.all
and I encountered the following error:
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
The text was updated successfully, but these errors were encountered: