tonybaloney / hubot-spark

A hubot integration for Cisco Spark
Apache License 2.0
14 stars 6 forks source link

Failed to authenticate: Invalid or missing credentials #16

Closed guillain closed 6 years ago

guillain commented 6 years ago

Hi Tony,

First of all thanks a lot for your dev !!! Sorry for this second line but I've issue even if all appear to be configured properly. Thanks in advance for your feedback and once again for your job :-D

Conf

# Cisco Spark settings (https://github.com/tonybaloney/hubot-spark):
export HUBOT_ADAPTER=spark
export HUBOT_SPARK_API_URI="https://api.ciscospark.com/v1"
export HUBOT_SPARK_ACCESS_TOKEN="xxxxxx"
export HUBOT_SPARK_ROOMS="yyyyyyyy"

Test

curl -X GET \
  https://api.ciscospark.com/v1/rooms/yyyyyyyy \
  -H 'Authorization: Bearer xxxxxx' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "StackStorm test"
}'

{"id":"zzzzzzzVk","title":"StackStorm test","type":"group","isLocked":false,"lastActivity":"2018-01-29T17:49:27.237Z","creatorId":"tttttttttttt","created":"2018-01-29T09:19:35.544Z"}

Log

[Mon Jan 29 2018 10:18:19 GMT+0000 (UTC)] DEBUG Loading adapter spark
[Mon Jan 29 2018 10:18:20 GMT+0000 (UTC)] INFO Trying connection to https://api.ciscospark.com/v1
one flight: attempted to invoke _getBinding while previous invocation still in flight
one flight: attempted to invoke _getBinding while previous invocation still in flight
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Connected as a bot? false
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] INFO Created connection instance to Spark
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Completed adding rooms to list
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Created bot, setting up listeners
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Done with custom bot logic
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Loading scripts from /opt/stackstorm/chatops/scripts
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Loading scripts from /opt/stackstorm/chatops/src/scripts
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] INFO Requesting a token...
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] WARNING No supported formatter found for spark. Using DefaultFormatter.
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Using spark post data handler.
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Parsing help for /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] DEBUG Parsing help for /opt/stackstorm/chatops/node_modules/hubot-help/src/help.coffee
[Mon Jan 29 2018 10:18:22 GMT+0000 (UTC)] ERROR Failed to authenticate: Invalid or missing credentials
(node:1085) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): [object Object]
tonybaloney commented 6 years ago

Did you use a Bot token or a user/dev token?

guillain commented 6 years ago

Hi Tony,

Tested many combinaison but better result with my personnal token (the previous log).

When I use the bot's token, I've this result:

[Tue Jan 30 2018 08:11:28 GMT+0000 (UTC)] DEBUG Loading adapter spark
[Tue Jan 30 2018 08:11:29 GMT+0000 (UTC)] INFO Trying connection to https://api.ciscospark.com/v1
one flight: attempted to invoke _getBinding while previous invocation still in flight
one flight: attempted to invoke _getBinding while previous invocation still in flight
(node:2485) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 17): Error: Failed to connect to Spark: Error: Authorization cannot be refreshed

When I use the app's token:

[Tue Jan 30 2018 08:15:20 GMT+0000 (UTC)] DEBUG Loading adapter spark
[Tue Jan 30 2018 08:15:21 GMT+0000 (UTC)] INFO Trying connection to https://api.ciscospark.com/v1
one flight: attempted to invoke _getBinding while previous invocation still in flight
one flight: attempted to invoke _getBinding while previous invocation still in flight
(node:2529) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 17): Error: Failed to connect to Spark: Error: Authorization cannot be refreshed

Thanks for your support ! :-)

guillain commented 6 years ago

The fault was mine and my conf :/ After have changed the st2 passwd Ive missed the update in the st2chat conf.

Sorry to have waste your time but thanks for your involvment and reactivity :)