Вопрос

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?

Это было полезно?

Решение

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)

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top