Added the ability to create an authorization object from client secrets.
This commit is contained in:
parent
2f630f6c1d
commit
2c567fd720
|
@ -1,3 +1,7 @@
|
|||
# 0.4.7
|
||||
|
||||
* Added the ability to convert client secrets to an authorization object
|
||||
|
||||
# 0.4.6
|
||||
|
||||
* Backwards compatibility for MultiJson
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "google-api-client"
|
||||
s.version = "0.4.6"
|
||||
s.version = "0.4.7"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Bob Aman"]
|
||||
s.date = "2012-08-30"
|
||||
s.date = "2012-10-05"
|
||||
s.description = "The Google API Ruby Client makes it trivial to discover and access supported\nAPIs.\n"
|
||||
s.email = "bobaman@google.com"
|
||||
s.executables = ["google-api"]
|
||||
s.extra_rdoc_files = ["README.md"]
|
||||
s.files = ["lib/compat", "lib/compat/multi_json.rb", "lib/google", "lib/google/api_client", "lib/google/api_client/batch.rb", "lib/google/api_client/client_secrets.rb", "lib/google/api_client/discovery", "lib/google/api_client/discovery/api.rb", "lib/google/api_client/discovery/media.rb", "lib/google/api_client/discovery/method.rb", "lib/google/api_client/discovery/resource.rb", "lib/google/api_client/discovery/schema.rb", "lib/google/api_client/discovery.rb", "lib/google/api_client/environment.rb", "lib/google/api_client/errors.rb", "lib/google/api_client/media.rb", "lib/google/api_client/reference.rb", "lib/google/api_client/result.rb", "lib/google/api_client/service_account.rb", "lib/google/api_client/version.rb", "lib/google/api_client.rb", "lib/google/inflection.rb", "spec/fixtures", "spec/fixtures/files", "spec/fixtures/files/sample.txt", "spec/google", "spec/google/api_client", "spec/google/api_client/batch_spec.rb", "spec/google/api_client/discovery_spec.rb", "spec/google/api_client/media_spec.rb", "spec/google/api_client/result_spec.rb", "spec/google/api_client/service_account_spec.rb", "spec/google/api_client_spec.rb", "spec/spec_helper.rb", "tasks/gem.rake", "tasks/git.rake", "tasks/metrics.rake", "tasks/spec.rake", "tasks/wiki.rake", "tasks/yard.rake", "CHANGELOG.md", "Gemfile", "Gemfile.lock", "LICENSE", "Rakefile", "README.md", "bin/google-api"]
|
||||
s.files = ["lib/compat", "lib/compat/multi_json.rb", "lib/google", "lib/google/api_client", "lib/google/api_client/batch.rb", "lib/google/api_client/client_secrets.rb", "lib/google/api_client/discovery", "lib/google/api_client/discovery/api.rb", "lib/google/api_client/discovery/media.rb", "lib/google/api_client/discovery/method.rb", "lib/google/api_client/discovery/resource.rb", "lib/google/api_client/discovery/schema.rb", "lib/google/api_client/discovery.rb", "lib/google/api_client/environment.rb", "lib/google/api_client/errors.rb", "lib/google/api_client/media.rb", "lib/google/api_client/reference.rb", "lib/google/api_client/result.rb", "lib/google/api_client/service_account.rb", "lib/google/api_client/version.rb", "lib/google/api_client.rb", "lib/google/inflection.rb", "spec/fixtures", "spec/fixtures/files", "spec/fixtures/files/sample.txt", "spec/google", "spec/google/api_client", "spec/google/api_client/batch_spec.rb", "spec/google/api_client/discovery_spec.rb", "spec/google/api_client/media_spec.rb", "spec/google/api_client/result_spec.rb", "spec/google/api_client/service_account_spec.rb", "spec/google/api_client_spec.rb", "spec/spec_helper.rb", "tasks/gem.rake", "tasks/git.rake", "tasks/metrics.rake", "tasks/spec.rake", "tasks/wiki.rake", "tasks/yard.rake", "CHANGELOG.md", "Gemfile", "LICENSE", "Rakefile", "README.md", "bin/google-api"]
|
||||
s.homepage = "http://code.google.com/p/google-api-ruby-client/"
|
||||
s.rdoc_options = ["--main", "README.md"]
|
||||
s.require_paths = ["lib"]
|
||||
|
|
|
@ -101,6 +101,33 @@ module Google
|
|||
end
|
||||
})
|
||||
end
|
||||
|
||||
def to_authorization
|
||||
gem 'signet', '~> 0.4.0'
|
||||
require 'signet/oauth_2/client'
|
||||
# NOTE: Do not rely on this default value, as it may change
|
||||
new_authorization = Signet::OAuth2::Client.new
|
||||
new_authorization.client_id = self.client_id
|
||||
new_authorization.client_secret = self.client_secret
|
||||
new_authorization.authorization_uri = (
|
||||
self.authorization_uri ||
|
||||
'https://accounts.google.com/o/oauth2/auth'
|
||||
)
|
||||
new_authorization.token_credential_uri = (
|
||||
self.token_credential_uri ||
|
||||
'https://accounts.google.com/o/oauth2/token'
|
||||
)
|
||||
new_authorization.redirect_uri = self.redirect_uris.first
|
||||
|
||||
# These are supported, but unlikely.
|
||||
new_authorization.access_token = self.access_token
|
||||
new_authorization.refresh_token = self.refresh_token
|
||||
new_authorization.id_token = self.id_token
|
||||
new_authorization.expires_in = self.expires_in
|
||||
new_authorization.issued_at = self.issued_at if self.issued_at
|
||||
new_authorization.expires_at = self.expires_at if self.expires_at
|
||||
return new_authorization
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ if !defined?(::Google::APIClient::VERSION)
|
|||
module VERSION
|
||||
MAJOR = 0
|
||||
MINOR = 4
|
||||
TINY = 6
|
||||
TINY = 7
|
||||
|
||||
STRING = [MAJOR, MINOR, TINY].join('.')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue