From 74bbfa22512a83b2d494930d181537890fa48e15 Mon Sep 17 00:00:00 2001 From: Michael Wawra Date: Tue, 26 Apr 2016 22:41:32 +0100 Subject: [PATCH] Allow symbols for credential flow Because of my production environment, adding a JSON file a little bit of a pain. However: using the intializer it's readily possible to set my credentials manually from my environment. I noticed that while all the credential details can be either a String or a Symbol, the 'flow' (i.e., `web`) **must** be a string. This allows it to accept both a string and a symbol. --- lib/google/api_client/client_secrets.rb | 2 +- spec/google/api_client/client_secrets_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/google/api_client/client_secrets.rb b/lib/google/api_client/client_secrets.rb index 64515efeb..76f270b6c 100644 --- a/lib/google/api_client/client_secrets.rb +++ b/lib/google/api_client/client_secrets.rb @@ -82,7 +82,7 @@ module Google def initialize(options={}) # Client auth configuration @flow = options[:flow] || options.keys.first.to_s || 'web' - fdata = options[@flow] + fdata = options[@flow.to_sym] || options[@flow] @client_id = fdata[:client_id] || fdata["client_id"] @client_secret = fdata[:client_secret] || fdata["client_secret"] @redirect_uris = fdata[:redirect_uris] || fdata["redirect_uris"] diff --git a/spec/google/api_client/client_secrets_spec.rb b/spec/google/api_client/client_secrets_spec.rb index 30c64c4cc..6daa5a372 100644 --- a/spec/google/api_client/client_secrets_spec.rb +++ b/spec/google/api_client/client_secrets_spec.rb @@ -215,7 +215,7 @@ RSpec.describe Google::APIClient::ClientSecrets do context 'option keys are symbol' do let(:symbol_options) do - { 'samples' => + { samples: { access_token: 'sample_access_token', auth_uri: 'sample_auth_uri',