3
votes

I've integrated Google Drive with my app and it was all working well until today. I didn't change any of the code or client ID's and now getting this error when authorizing GDrive on our site:

Google::APIClient::ClientError

Could not retrieve discovery document at: https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest

I'm using the Ruby Google Api Client, here's the code where the error is thrown:

require 'google/api_client'

      gclient ||= (begin
      client = Google::APIClient.new
      client.authorization.client_id = Rails.application.config.gdrive_client_id
      client.authorization.client_secret = Rails.application.config.gdrive_client_secret
      client.authorization.redirect_uri = "#{request.protocol}#{Rails.application.config.host_url}/users/auth/gdrive"
      client.authorization.access_token = auth_token.token
      client.authorization.scope = [
        "https://www.googleapis.com/auth/drive",
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/userinfo.profile"
      ]
      client
    end)
    result = gclient.execute!(
      :api_method => 'oauth2.userinfo.get',
      :version => 'v2'
    )

The error comes up at "result = gclient.execute!". Did something change in the Google Ruby API client library?

2
Looks like this is a Google issue, I got the exact same error when trying to open a Google Drive image with a couple other applications.ramz15

2 Answers

2
votes

No - nothing changed in the Ruby libraries. This is caused by a change to the webservices which Google provides at https://www.googleapis.com/discovery/v1/apis.

I know this, because I hit this same problem today from the python API library.

I have found a partial work-around, which is to avoid using the discovery service and hit the URL directly. The URL for the OAuth2 userinfo service is

https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=USER_TOKEN_HERE

This isn't a great long-term solution, but hopefully will hold you over until google fixes their discovery service.

UPDATE - looks like it's back up for now (as of August 16th, 2:07PST)

0
votes

There used to be

{ "id": "oauth:v2", "name": "oauth", "version": "v2" ... }

on https://www.googleapis.com/discovery/v1/apis

It's not there now. That's the problem.

That's a symptom of the problem.