From f9c1ab67ba7f2bccc92e219648d4676550cb4318 Mon Sep 17 00:00:00 2001 From: Steven Bazyl Date: Mon, 24 Sep 2012 15:21:56 -0700 Subject: [PATCH] Update example in readme --- README.md | 51 ++++++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index f9942aec1..c35e11f91 100644 --- a/README.md +++ b/README.md @@ -17,46 +17,31 @@ APIs. # Example Usage - # Initialize the client + # Initialize the client & Google+ API require 'google/api_client' - require 'signet/oauth_1/client' - client = Google::APIClient.new( - :service => 'buzz', - # Buzz has API-specific endpoints - :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' - } - ) - redirect_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') + client = Google::APIClient.new + plus = client.discovered_api('plus') + + # Initialize OAuth 2.0 client + client.authorization.client_id = '' + client.authorization.client_secret = '' + client.authorization.scope = 'https://www.googleapis.com/auth/plus.me' - # Discover available methods - method_names = client.discovered_api('plus').to_h.keys + # Request authorization + redirect_uri = client.authorization.authorization_uri + + # Wait for authorization code then exchange for token + client.authorization.code = '....' + client.authorization.fetch_access_token! # Make an API call result = client.execute( - 'plus.activities.list', - {'collection' => 'public', 'userId' => 'me'} + :api_method => plus.activities.list' + :parameters => {'collection' => 'public', 'userId' => 'me'} ) + puts result.data + # Install Be sure `http://rubygems.org/` is in your gem sources.