Вопрос

I'm using the Google Signet Client in a Rails app to access Google APIs, right now the Provisioning API mostly, through OAuth 1. Google just came out with a new set of APIs under the Admin SDK moniker. Specifically, I'm interested in a function of the Directory API. Unfortunately, the Directory API keeps returning an 'Invalid Credentials' response through the signet client.

Authentication for my OAuth happens through Google Marketplace to do keys and whatnot. Here's a sample on how the code generates the client:

oauth_args = {
  :authorization_uri => "https://www.google.com/accounts/OAuthAuthorizeToken",
  :token_credential_uri =>"https://www.google.com/accounts/OAuthGetAccessToken",
  :client_credential_key => < google_marketplace_consumer_key >,
  :client_credential_secret => < google_marketplace_consumer_secret >
}

client = Signet::OAuth1::Client.new(oauth_args)
client.two_legged = true
client.requestor_id = self.owner.email
client.get(:uri=>'https://www.googleapis.com/admin/directory/v1/users?key=<api key>&domain=< my test domain >')

Oddly, this same request works just fine through the OAuth1 playground, using the same test keys that I use in my local environment, but everytime I hit the Directory API I get the same 'Invalid Credentials'. Also note that, save for the URL being requested, this is the same code that I use to hit the Provisioning API.

Anyone know why this API specifically seems to have a problem with either the client or how I'm auth'ing? I have enabled the API for my account.

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

Решение

Had nothing to do with the signet client in the end, but just with the Google Marketplace permissions; the 'Invalid Credentials' error was more of a red herring. Did the steps listed at Migrate application developed with the Provisioning API to the new api (Admin SDK) and it worked; I had enabled the API for my app, but hadn't updated the manifest.

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