whitespace cleanup in readme
This commit is contained in:
parent
f7307ec35d
commit
2a975aa877
26
README.md
26
README.md
|
@ -33,11 +33,11 @@ require 'google/api_client'
|
||||||
client = Google::APIClient.new
|
client = Google::APIClient.new
|
||||||
plus = client.discovered_api('plus')
|
plus = client.discovered_api('plus')
|
||||||
|
|
||||||
# Initialize OAuth 2.0 client
|
# Initialize OAuth 2.0 client
|
||||||
client.authorization.client_id = '<CLIENT_ID_FROM_API_CONSOLE>'
|
client.authorization.client_id = '<CLIENT_ID_FROM_API_CONSOLE>'
|
||||||
client.authorization.client_secret = '<CLIENT_SECRET>'
|
client.authorization.client_secret = '<CLIENT_SECRET>'
|
||||||
client.authorization.redirect_uri = '<YOUR_REDIRECT_URI>'
|
client.authorization.redirect_uri = '<YOUR_REDIRECT_URI>'
|
||||||
|
|
||||||
client.authorization.scope = 'https://www.googleapis.com/auth/plus.me'
|
client.authorization.scope = 'https://www.googleapis.com/auth/plus.me'
|
||||||
|
|
||||||
# Request authorization
|
# Request authorization
|
||||||
|
@ -81,10 +81,10 @@ my_api = client.register_discovery_document('myapi', 'v1', doc)
|
||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
Most interactions with Google APIs require users to authorize applications via OAuth 2.0. The client library uses [Signet](https://github.com/google/signet) to handle most aspects of authorization. For additional details about Google's OAuth support, see [Google Developers](https://developers.google.com/accounts/docs/OAuth2).
|
Most interactions with Google APIs require users to authorize applications via OAuth 2.0. The client library uses [Signet](https://github.com/google/signet) to handle most aspects of authorization. For additional details about Google's OAuth support, see [Google Developers](https://developers.google.com/accounts/docs/OAuth2).
|
||||||
|
|
||||||
Credentials can be managed at the connection level, as shown, or supplied on a per-request basis when calling `execute`.
|
Credentials can be managed at the connection level, as shown, or supplied on a per-request basis when calling `execute`.
|
||||||
|
|
||||||
For server-to-server interactions, like those between a web application and Google Cloud Storage, Prediction, or BigQuery APIs, use service accounts.
|
For server-to-server interactions, like those between a web application and Google Cloud Storage, Prediction, or BigQuery APIs, use service accounts.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
@ -97,8 +97,8 @@ client.authorization = Signet::OAuth2::Client.new(
|
||||||
:signing_key => key)
|
:signing_key => key)
|
||||||
client.authorization.fetch_access_token!
|
client.authorization.fetch_access_token!
|
||||||
client.execute(...)
|
client.execute(...)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Batching Requests
|
### Batching Requests
|
||||||
|
|
||||||
Some Google APIs support batching requests into a single HTTP request. Use `Google::APIClient::BatchRequest`
|
Some Google APIs support batching requests into a single HTTP request. Use `Google::APIClient::BatchRequest`
|
||||||
|
@ -109,18 +109,18 @@ Example:
|
||||||
```ruby
|
```ruby
|
||||||
client = Google::APIClient.new
|
client = Google::APIClient.new
|
||||||
urlshortener = client.discovered_api('urlshortner')
|
urlshortener = client.discovered_api('urlshortner')
|
||||||
|
|
||||||
batch = Google::APIClient::BatchRequest.new do |result|
|
batch = Google::APIClient::BatchRequest.new do |result|
|
||||||
puts result.data
|
puts result.data
|
||||||
end
|
end
|
||||||
|
|
||||||
batch.add(:api_method => urlshortener.url.insert,
|
batch.add(:api_method => urlshortener.url.insert,
|
||||||
:body_object => { 'longUrl' => 'http://example.com/foo' })
|
:body_object => { 'longUrl' => 'http://example.com/foo' })
|
||||||
batch.add(:api_method => urlshortener.url.insert,
|
batch.add(:api_method => urlshortener.url.insert,
|
||||||
:body_object => { 'longUrl' => 'http://example.com/bar' })
|
:body_object => { 'longUrl' => 'http://example.com/bar' })
|
||||||
client.execute(batch)
|
client.execute(batch)
|
||||||
```
|
```
|
||||||
|
|
||||||
Blocks for handling responses can be specified either at the batch level or when adding an individual API call. For example:
|
Blocks for handling responses can be specified either at the batch level or when adding an individual API call. For example:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
@ -136,7 +136,7 @@ uploads can be used. For example, to upload a file to Google Drive using multipa
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
drive = client.discovered_api('drive', 'v2')
|
drive = client.discovered_api('drive', 'v2')
|
||||||
|
|
||||||
media = Google::APIClient::UploadIO.new('mymovie.m4v', 'video/mp4')
|
media = Google::APIClient::UploadIO.new('mymovie.m4v', 'video/mp4')
|
||||||
metadata = {
|
metadata = {
|
||||||
'title' => 'My movie',
|
'title' => 'My movie',
|
||||||
|
@ -147,7 +147,7 @@ client.execute(:api_method => drive.files.insert,
|
||||||
:body_object => metadata,
|
:body_object => metadata,
|
||||||
:media => media )
|
:media => media )
|
||||||
```
|
```
|
||||||
|
|
||||||
To use resumable uploads, change the `uploadType` parameter to `resumable`. To check the status of the upload
|
To use resumable uploads, change the `uploadType` parameter to `resumable`. To check the status of the upload
|
||||||
and continue if necessary, check `result.resumable_upload`.
|
and continue if necessary, check `result.resumable_upload`.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue