Pergunta

I've created a Google Apps Marketplace app and I'm trying to get a list of all users of a Google apps domain with a call to the Google Apps Provisioning API but can't get past this error:

#<Net::HTTPBadRequest 400 Bad Request readbody=true> 

Here is the code I'm using:

consumer = OAuth::Consumer.new(my_google.oauth_key,
                               my_google.oauth_secret,
                               :site => 'https://apps-apis.google.com/a/feeds/user/#readonly',
                               :http_method => :get)
access_token = OAuth::AccessToken.new consumer
result = access_token.get("https://apps-apis.google.com/a/feeds/my_domain.com/user/2.0?alt=json")

I also have this in my Google Apps manifest file:

<Scope id="scopeUsers">
  <Url>https://apps-apis.google.com/a/feeds/user/#readonly</Url>
  <Reason>Our App will be setup for your entire domain.</Reason>
</Scope>

I've verified the oauth_key and secret and have tried many other possibilities but just can't get to the bottom of this. Is there anything I'm missing here? Any other options I could try?

Foi útil?

Solução 2

I figured the issue out. It was a problem with the OAuth gem version, I was using OAuth 0.4.6 and need to use OAuth 0.4.5 to be compatible with the syntax I was using.

Outras dicas

The HTTP Response also includes a more descriptive error message explaining why your request is invalid. I don't know about the Ruby library but there must be a way to access that field. If not, you can also use a tool like Wireshark or Fiddler to capture the traffic and inspect the response.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top