cdimascio / nationalparks_conversation

Chatbots and Watson: Let’s talk about national parks: course source code
https://developer.ibm.com/courses/all-courses/chatbots-and-watson-lets-talk-about-national-parks/
46 stars 74 forks source link

Lab 5: Authentication Problem on Windows #7

Closed christophkormesser closed 6 years ago

christophkormesser commented 6 years ago

Hello @cdimascio , I am currently trying to recreate the chatbot, but fail at module 41.

This is my error:

{ Error: Unauthorized: Access is denied due to invalid credentials. ... code: 401, error: 'Not Authorized', description: '2018-05-25T11:14:24-05:00, Error ERCDPLTFRM-DNLKUPERR occurred when accessing https://gateway.watsonplatform.net/conversation/api/v1/workspaces/%3C86181bd0-cf0e-44a2-8eb5-c80bd2c2d5a1%3E/message?version=2016-09-20, Tran-Id: gateway01-59613562 - Invalid UserId and/or Password. Please confirm that your credentials match the end-point you are trying to access. A common error is trying to use credentials from an experimental or beta release against a GA release or vice versa', body: 'Not Authorized', 'x-global-transaction-id': undefined }

I am very certain that I used the right credentials and workspace id. Is there an issue with the url or the new name of watson conversation to watson assistant? (BTW I do not really have any programming skills).

Thanks in advance!

cdimascio commented 6 years ago

Are you using Windows?

christophkormesser commented 6 years ago

Yes, Windows 10.

cdimascio commented 6 years ago

Ok I think it may be an issue with the name of the USERNAME and PASSWORD env vars. I believe those names collide with the windows environment.

One thing you can do is update those vars in .env to something else BM_USERNAME and BM_PASSWORD, then update all calls in the source code from process.env.USERNAME and process.env.PASSWORD to process.env.BM_USERNAME, process.env.BM_PASSWORD

Id this is too complicated, I'll get to it on Tuesday

christophkormesser commented 6 years ago

Thank you for the response I'll try it in a few days!

christophkormesser commented 6 years ago

So I changed the variables to BM_USERNAME, BM_PASSWORD in the .env file and the index.js but the same error occurred. (also tried changing WORKSPACE_ID to BM_WORKSPACE_ID)

cdimascio commented 6 years ago

@christophkormesser im wrong. after viewing the code, i see i was confusing this project with another. all in all, the variables in .env should work as expected on Windows. all in all, revert the changes i noted above. apologies for the confusion.

that being, the case, we still dont know why you're experiencing issues. once you revert to the original .env var names, can you paste that here (with your passwords masked out) also please supply you node.js and npm version

christophkormesser commented 6 years ago

npm version:

2018-06-11 15_05_10- index js - example - visual studio code

node.js:

2018-06-11 15_22_11-node js command prompt

.env file: inked2018-06-11 14_58_20- env - example - visual studio code_li

index.js:

2018-06-11 14_59_31-index js - example - visual studio code
cdimascio commented 6 years ago

@christophkormesser i'm a bit stumped why that is not working for you, given it is essentially just calling the conversation sdk directly. One way to avoid any potential environment and/or .env issue is to replace process.env.USERNAME and process.env.PASSWORD with the actual username and password strings. This is clearly not recommended for a production system, but should be perfectly fine for purposes of the course

Also, with respect to env vars, one more thing to to try... Check the value of the actual environment variable. Any value in the actual environment will override what is in .env; You can check with echo %USERNAME% and echo %PASSWORD%

cdimascio commented 6 years ago

The issues occurs on Windows.

I've posted instructions to workaround this issue in the README