0

I have cloned the Concept Insights demo from Bluemix and made some minor changes to use my own corpus. It runs OK locally, but when I deploy it to Bluemix I get an authorization error when it tries to access my corpus. I'm certain that the error is a result of the early call in app.js to bluemix.getServiceCreds('concept_insights'), which apparently replaces my service credentials with some that must be stored in the environment on Bluemix.

Can someone explain the purpose of this function, and the proper approach to what I am trying to do? I could probably just delete the call to that function, but I'm afraid that I may be missing part of the larger picture if I do. Is this a way to keep my credentials out of the code base? If so, how do I make it work?

orome
  • 45,163
  • 57
  • 202
  • 418
David Powell
  • 537
  • 1
  • 4
  • 16

1 Answers1

0

bluemix.getServiceCreds('concept_insights') gets the concept_insights service credentials from the VCAP_SERVICES variable that is created by Bluemix. (see VCAP_SERVICES)
You probably want to use the credentials from the environment instead of hardcoding them in your app.js file.

When your app runs locally you hardcode the credentials in app.js, but when it runs in Bluemix those credentials are overwritten. If you don't want this to happen remove the bluemix.getServiceCreds('concept_insights')

var credentials = {
  url: 'https://gateway.watsonplatform.net/concept-insights/api',
  username: '<username>',
  password: '<password>',
  version: 'v2'
};

When creating a service make sure you use the Standard plan. Standard plan

If you use the Beta plan you will have to use https://gateway.watsonplatform.net/concept-insights/api as url.

herchu
  • 936
  • 7
  • 24
German Attanasio
  • 22,217
  • 7
  • 47
  • 63