Skip to content

Commit f3e8a5b

Browse files
committed
more apikey/apikey stuff
1 parent f7e546b commit f3e8a5b

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# v2.4.2
1+
# v2.4.3
22
* Fix issue with automatically loading Alchemy* credentials from the Bluemix environment
33

44
# v2.4.1

lib/base_service.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
var extend = require('extend');
2020
var vcapServices = require('vcap_services');
2121
var helper = require('./helper');
22-
var omit = require('object.omit');
2322
var request = require('request');
2423

2524

@@ -44,8 +43,6 @@ function BaseService(user_options) {
4443

4544
options = this.initCredentials(options);
4645

47-
options = omit(options, ['version', 'username', 'password', 'use_unauthenticated', 'apikey']);
48-
4946
if (options.url)
5047
options.url = helper.stripTrailingSlash(options.url);
5148

lib/base_service_alchemy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ util.inherits(BaseServiceAlchemy, BaseService);
2222
* @private
2323
*/
2424
BaseServiceAlchemy.prototype.initCredentials = function(options) {
25-
options.api_key = options.apikey || options.api_key;
25+
options.apikey = options.apikey || options.api_key;
2626
options = extend(
2727
{},
2828
this.getCredentialsFromBluemix('alchemy_api'), // this is the same for all Alchemy* services
2929
this.getCredentialsFromEnvironment(this.name),
3030
options
3131
);
3232
if (!options.use_unauthenticated) {
33-
if (!options.api_key) {
33+
if (!options.apikey) {
3434
throw new Error('Argument error: api_key was not specified');
3535
}
3636
// Per documentation, Alchemy* services use `apikey`, but Visual Recognition uses (`api_key`)
3737
// (Either will work in most cases, but there are a few exceptions.)
38-
options.qs = extend({ apikey : options.api_key }, options.qs);
38+
options.qs = extend({ apikey : options.apikey }, options.qs);
3939
}
4040
return options
4141
};
@@ -48,7 +48,7 @@ BaseServiceAlchemy.prototype.initCredentials = function(options) {
4848
*/
4949
BaseServiceAlchemy.prototype.getCredentialsFromEnvironment = function(name) {
5050
return {
51-
api_key: process.env[name.toUpperCase() + '_API_KEY']
51+
apikey: process.env[name.toUpperCase() + '_API_KEY']
5252
}
5353
};
5454

test/test.wrapper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ describe('wrapper', function() {
108108

109109
it('should use apikey (not documented) for alchemy service', function() {
110110
var service = watson.alchemy_language({ apikey: 'not-gonna-work'});
111-
assert.equal(service._options.api_key, 'not-gonna-work');
111+
assert.equal(service._options.qs.apikey, 'not-gonna-work');
112112
});
113113

114114
it('should use api_key for alchemy service', function() {
115115
var service = watson.alchemy_language({ api_key: 'not-gonna-work'});
116-
assert.equal(service._options.api_key, 'not-gonna-work');
116+
assert.equal(service._options.qs.apikey, 'not-gonna-work');
117117
});
118118

119119
it('should not use VCAP_SERVICES if use_vcap_services is false', function() {

0 commit comments

Comments
 (0)