get-started-python icon indicating copy to clipboard operation
get-started-python copied to clipboard

VCAP_Services Error

Open movinglightspeed opened this issue 4 years ago • 3 comments

https://github.com/IBM-Cloud/get-started-python/blob/master/hello.py

Waiting for app to start... Start unsuccessful

TIP: use 'cf.exe logs myapp --recent' for more information FAILED

ibmcloud cf logs myapp --recent 2021-01-12T06:02:32.28-0600 [CELL/0] OUT Starting health monitoring of container 2021-01-12T06:02:39.91-0600 [APP/PROC/WEB/0] ERR Traceback (most recent call last): 2021-01-12T06:02:39.91-0600 [APP/PROC/WEB/0] OUT Found VCAP_SERVICES 2021-01-12T06:02:39.94-0600 [APP/PROC/WEB/0] ERR File "hello.py", line 19, in 2021-01-12T06:02:39.94-0600 [APP/PROC/WEB/0] ERR password = creds['password'] 2021-01-12T06:02:39.94-0600 [APP/PROC/WEB/0] ERR KeyError: 'password' 2021-01-12T06:02:40.43-0600 [APP/PROC/WEB/0] OUT Exit status 1 2021-01-12T06:02:40.49-0600 [CELL/SSHD/0] OUT Exit status 0

From GUI TypeInstanceLogsTime APP/PROC/WEB0Traceback (most recent call last):

Jan 12, 2021, 05:42:07 AM

APP/PROC/WEB0 File "hello.py", line 19, in

Jan 12, 2021, 05:42:07 AM APP/PROC/WEB0 password = creds['password']

Jan 12, 2021, 05:42:07 AM APP/PROC/WEB0KeyError: 'password'

Jan 12, 2021, 05:42:07 AM

movinglightspeed avatar Jan 12 '21 12:01 movinglightspeed

update: I realized the reason was because the cloudant database was IAM only not IAM + Legacy which supports the username + password.

It would be good if the code was updated to support also the IAM only cloudant database offering, offering support for the IAM apikey + access token support as iam apikey alone can't authenticate against a cloudant database as stated from docs:

https://github.com/IBM/cloudant-python-sdk#iam-authentication

"You can't use an IAM API key directly to authenticate against IBM Cloudant." https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-connecting

It would be great to see a implementation of IAM API key + Access token in a python app starter code

movinglightspeed avatar Jan 12 '21 12:01 movinglightspeed

Just to clarify, while you can't use an IAM API key directly when using cURL (you must first get an IBM Cloud IAM token by using an API key) you can use the IAM API key to authenticate in our python-cloudant library. There's an example of authenticating with IAM in our python-cloudant documentation.

emlaver avatar Jan 12 '21 17:01 emlaver

@emlaver Thanks for clarifying that! That was it, that statement in the documentation caused alot of confusion. To further add to my wrong conclusions, starter kits all used legacy creds, led me to believe iam didn't work for apps and thought what a security risk!

This cleared it up and I used the code in the example you shared and successfully tested an app connection to the db. I was able to create, update using iam connection.

movinglightspeed avatar Jan 15 '21 04:01 movinglightspeed