ibm-bluemix-mobile-services / bms-mca-token-validation-strategy

Apache License 2.0
1 stars 0 forks source link

TypeError: Can't get serverUrl from VCAP_SERVICES #9

Closed slaupster closed 7 years ago

slaupster commented 7 years ago

I get this:

2017-03-23T11:02:38.20+0000 [APP/0] ERR /home/vcap/app/node_modules/bms-mca-token-validation-strategy/lib/imf-backend-strategy.js:35 2017-03-23T11:02:38.20+0000 [APP/0] ERR throw new TypeError(msg); 2017-03-23T11:02:38.20+0000 [APP/0] ERR ^ 2017-03-23T11:02:38.20+0000 [APP/0] ERR TypeError: Can't get serverUrl from VCAP_SERVICES, please check if the application running on bluemix or bind with IBM MobileFirst Platform service. 2017-03-23T11:02:38.20+0000 [APP/0] ERR at new Strategy (/home/vcap/app/node_modules/bms-mca-token-validation-strategy/lib/imf-backend-strategy.js:35:9) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at Object. (/home/vcap/app/app.js:180:14) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at Module._compile (module.js:409:26) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at Object.Module._extensions..js (module.js:416:10) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at Module.load (module.js:343:32) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at Function.Module._load (module.js:300:12) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at Function.Module.runMain (module.js:441:10) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at startup (node.js:139:18) 2017-03-23T11:02:38.20+0000 [APP/0] ERR at node.js:990:3

Comparing filter-util.js and the env:

{ "VCAP_SERVICES": { "AdvancedMobileAccess": [ { "credentials": { "clientId": "1e200ef9-6f47-4e09-b25e-6963d4dc2c2b", "oauthServerUrl": "https://appid-oauth.eu-gb.bluemix.net/oauth/v3/0f692c0c-8621-43ed-bac7-c77ceb064b51", "profilesUrl": "https://appid-profiles.eu-gb.bluemix.net", "secret": "OGQ3MmMyM2YtNWY5ZC00NDYwLThhYTctZTkzYTZiOTliNGIz", "tenantId": "0f692c0c-8621-43ed-bac7-c77ceb064b51", "version": 3 },

we can see that

var serverUrl = imfService && imfService['credentials'] && imfService['credentials']['serverUrl'];

is looking for something that does not exist, but I'm not sure what it should be looking for.

rotembr commented 7 years ago

If you are using App ID service instance please work with the new strategies: https://github.com/ibm-cloud-security/appid-serversdk-nodejs

(This repo strategies is for old MCA service instances)