From de394a55c6c7b107b20661253748ea984e748d0b Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Thu, 7 Oct 2010 22:12:27 +0000 Subject: [PATCH] Updated example. git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@44 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef --- README | 25 ++++++++++++++++++++++--- lib/google/api_client.rb | 8 ++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README b/README index 9582150d6..c069b8d56 100644 --- a/README +++ b/README @@ -13,18 +13,37 @@ APIs. == Example Usage require 'google/api_client' - client = Google::APIClient.new(:service => 'buzz') + require 'signet/oauth_1/client' + client = Google::APIClient.new( + :service => 'buzz', + :authorization => Signet::OAuth1::Client.new( + :temporary_credential_uri => + 'https://www.google.com/accounts/OAuthGetRequestToken', + :authorization_uri => + 'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken', + :token_credential_uri => + 'https://www.google.com/accounts/OAuthGetAccessToken', + :client_credential_key => 'anonymous', + :client_credential_secret => 'anonymous' + ) + ) client.authorization.fetch_temporary_credential!( :additional_parameters => { 'scope' => 'https://www.googleapis.com/auth/buzz' } ) - client.authorization.authorization_uri + client.authorization.authorization_uri( + :additional_parameters => { + 'domain' => client.authorization.client_credential_key, + 'scope' => 'https://www.googleapis.com/auth/buzz' + } + ) # Redirect user here client.authorization.fetch_token_credential!(:verifier => '12345') response = client.execute( 'buzz.activities.list', - 'scope' => '@self', 'userId' => '@me', 'alt' => 'json' + {'scope' => '@self', 'userId' => '@me', 'alt' => 'json'}, + '', [], {:signed => true} ) status, headers, body = response diff --git a/lib/google/api_client.rb b/lib/google/api_client.rb index 6ea179b0b..3ebb9e98f 100644 --- a/lib/google/api_client.rb +++ b/lib/google/api_client.rb @@ -298,6 +298,14 @@ module Google # otherwise. Defaults to true. # # @return [Array] The response from the API. + # + # @example + # response = client.execute( + # 'chili.activities.list', + # {'scope' => '@self', 'userId' => '@me', 'alt' => 'json'}, + # '', [], {:signed => true} + # ) + # status, headers, body = response def execute(api_method, parameters={}, body='', headers=[], options={}) request = self.generate_request( api_method, parameters, body, headers, options