Mostly doc updates, +remove support for method as string
[arvados.git] / README.md
index 6e7557f45ef1e3b2dece52652140b98f645961b1..c35e11f911779c80b9eb0b9296542bea8b6b3469 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,68 +1,56 @@
-== APIClient
+# APIClient
 
-Homepage::  google-api-ruby-client[http://code.google.com/p/google-api-ruby-client/]
-Authors::   Bob Aman (mailto:bobaman@google.com), Matt Pokrzywa (mailto:mattpok@google.com)
-Copyright:: Copyright 2010 Google Inc.
-License::   Apache 2.0
+<dl>
+  <dt>Homepage</dt><dd><a href="http://code.google.com/p/google-api-ruby-client">http://code.google.com/p/google-api-ruby-client</a></dd>
+  <dt>Author</dt><dd><a href="mailto:bobaman@google.com">Bob Aman</a></dd>
+  <dt>Copyright</dt><dd>Copyright © 2011 Google, Inc.</dd>
+  <dt>License</dt><dd>Apache 2.0</dd>
+</dl>
 
-== Description
+[![Build Status](https://secure.travis-ci.org/google/google-api-ruby-client.png)](http://travis-ci.org/google/google-api-ruby-client)
+[![Dependency Status](https://gemnasium.com/google/google-api-ruby-client.png)](https://gemnasium.com/google/google-api-ruby-client)
+
+# Description
 
 The Google API Ruby Client makes it trivial to discover and access supported
 APIs.
 
-== Example Usage
-
-  # Initialize the client
-  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'
+# Example Usage
+
+    # Initialize the client & Google+ API
+    require 'google/api_client'
+    client = Google::APIClient.new
+    plus = client.discovered_api('plus')
+
+    # Initialize OAuth 2.0 client    
+    client.authorization.client_id = '<CLIENT_ID_FROM_API_CONSOLE>'
+    client.authorization.client_secret = '<CLIENT_SECRET>'
+    client.authorization.scope = 'https://www.googleapis.com/auth/plus.me'
+    
+    # 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(
+      :api_method => plus.activities.list'
+      :parameters => {'collection' => 'public', 'userId' => 'me'}
     )
-  )
-  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')
-
-  # Discover available methods
-  method_names = client.discovered_api('buzz').to_h.keys
-
-  # Make an API call
-  response = client.execute(
-    'chili.activities.list',
-    {'scope' => '@self', 'userId' => '@me', 'alt' => 'json'}
-  )
-  status, headers, body = response
 
-== Install
+    puts result.data
+    
+# Install
 
-Be sure both http://gems.github.com/ and http://rubygems.org/ are in your gem
-sources.
+Be sure `http://rubygems.org/` is in your gem sources.
 
 For normal client usage, this is sufficient:
 
-sudo gem install google-api-client
+    $ sudo gem install google-api-client
 
 The command line interface, the example applications, and the test suite
 require additional dependencies. These may be obtained with:
 
-sudo gem install google-api-client --development --force --no-rdoc --no-ri
+    $ sudo gem install google-api-client --development --force --no-rdoc --no-ri