Can't impersonate on a service-to-service oauth request to google calendar api in ruby -


Hello, I was testing Google API customer for late night hacking and ruby. I

I've already done

  • I have already fallen into an error Has created an app in the Google Developer Console
  • I have enabled Calendar API
  • I created the server key and downloaded p12.
  • I understand that the calendar has been successful in seeing the use of Google API Explorer and Browser OAuth metadata, and can verify the OAuth metadata of the browser in the form of ID permissions as well.

What I am triying to do:

I am triying to get metadata (I will try events from a shared calendar personally , Where I serve at Ruby on service for the service

How Do I Trial

with this code:

P>
  Required 'google / api_client' requirement 'PP' client = Google :: APIClient .new calories = 'client.iscovered_api' ('calendar', 'v3') id ='xxxxxxxxxxxxxxxxxxxxxx@group.calendar .google.com '# ID is confirmation of this calendar ID key = Google :: APIClient :: KeyUtils.load_from_pkcs12 (' sl .p12 ',' notasecret ') client.authorization = Signet :: OAuth2 :: Client.new ( : Token_credential_uri = & gt; 'Http: //accounts.google.com/o/oauth2/token' ,:viewer = & gt; 'Http: //accounts.google.com/o/oauth2/token' ,: scope = & gt; 'Http: //www.googleapis.com/auth/calendar' ,: Issuer = & gt; 'Xxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com', # Confirmation Issuer: sign_key = & gt; Key) client.authorization.fetch_access_token! Results = client.execute (: api_method = & gt; cal.calendars.get ,: parameter = & gt; {'calendarId' = & gt; id}) results.response.body puts PP results  

The results colected

When I get a 404 to do this, something like "calendar does not exist"

  {"error": {"errors "]" Code ": 404," message ":" did not get "}}"   ["domain": "global", "reason": "no", "message": "did not get" / Pre 

  {"kind": "calendar # calendar", "etag": "\" "dAAhx6wYoPw2vqRAe54lk5v0xq / WEglF6_c5pVHKyggcENvvX1cS9g \" id ":" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com " , Issuer Id As the #same ??? WTF "Summary": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com" "Time zone": "UTC"}  

Which one is going to be a calendar , But it is "like the default calendar for email, the issuer" which appears in the "Email" field of the server

I also ad : person = 'email' Tried the field to client.authorization > but then I get an error in creating auth token

let me know from the API @ developer.gserviceaccount.com There was no way to get another form of mail account, so I am doing wrong.

You can either share the calendar with the service account's email or follow the service account to allow it to impersonate any user on that domain, in which case you have to pass the : person => gt; ; 'Email' parameter.


Comments