Merge pull request #31 from dwilkie/load_credentials_from_env

Fix bug when loading credentials from ENV
This commit is contained in:
Tim Emiola 2015-07-07 15:24:41 +01:00
commit 900d74729c
2 changed files with 6 additions and 3 deletions

View File

@ -67,9 +67,9 @@ module Google
json_key_io, scope = options.values_at(:json_key_io, :scope) json_key_io, scope = options.values_at(:json_key_io, :scope)
user_creds = self.class.read_json_key(json_key_io) if json_key_io user_creds = self.class.read_json_key(json_key_io) if json_key_io
user_creds ||= { user_creds ||= {
client_id: ENV[CredentialsLoader::CLIENT_ID_VAR], 'client_id' => ENV[CredentialsLoader::CLIENT_ID_VAR],
client_secret: ENV[CredentialsLoader::CLIENT_SECRET_VAR], 'client_secret' => ENV[CredentialsLoader::CLIENT_SECRET_VAR],
refresh_token: ENV[CredentialsLoader::REFRESH_TOKEN_VAR] 'refresh_token' => ENV[CredentialsLoader::REFRESH_TOKEN_VAR]
} }
super(token_credential_uri: TOKEN_CRED_URI, super(token_credential_uri: TOKEN_CRED_URI,

View File

@ -142,6 +142,9 @@ describe Google::Auth::UserRefreshCredentials do
ENV[REFRESH_TOKEN_VAR] = cred_json[:refresh_token] ENV[REFRESH_TOKEN_VAR] = cred_json[:refresh_token]
ENV[ACCOUNT_TYPE_VAR] = cred_json[:type] ENV[ACCOUNT_TYPE_VAR] = cred_json[:type]
expect(@clz.from_env(@scope)).to_not be_nil expect(@clz.from_env(@scope)).to_not be_nil
expect(subject.client_id).to eq(cred_json[:client_id])
expect(subject.client_secret).to eq(cred_json[:client_secret])
expect(subject.refresh_token).to eq(cred_json[:refresh_token])
end end
end end