[ERR] The security token included in the request is invalid

amazon-alexa
cli

#1

Trying to deploy my Alexa Skill using Jovo CLI.

Any idea how to fix this error?

Command:
jovo deploy --stage dev --target lambda -p alexaSkill

Error:
[ERR] The security token included in the request is invalid.


#2

I was able to solve this locally.

Local Solution:

  1. run: ask configure
  2. run: jovo deploy --stage dev --target lambda -p alexaSkill
  3. If the ASK-Profile you set up is named something other than default, run: jovo deploy --stage dev --target lambda -p alexaSkill --ask-profile profile-name

Still trying to figure out credentials in Gitlab CI/CI pipeline.

Stay tuned…


#3

Here’s how to fix this on Gitlab CI/CD Pipelines.

Generate LWA token

  1. use ask util generate-lwa-tokens to generate LWA token.

Add Environment Variables to Gitlab

  1. Open your project in Gitlab.
  2. Go to Settings -> CI/CD.
  3. Expand Variables.
  4. Add Variable ASK_VENDOR_ID
  5. Add Variable ASK_REFRESH_TOKEN (Found in LWA credentials above).

Update Gitlab CI/CD YAML file

  1. Make sure you use this command to deploy to Alexa: jovo deploy --stage dev -p alexaSkill --ask-profile __ENVIRONMENT_ASK_PROFILE__
  2. __ENVIRONMENT_ASK_PROFILE__ ensures ask-cli uses environment variables for credentials instead of looking for credentials files.

That should be all you need to do! If we missed something, tag @Voice_First and we will help you out.

Here’s the .gitlab-ci.yml file we used:

stages:
  - dev
  - test
  - production
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: <our-image>

# This folder is cached between builds
# http://docs.gitlab.com/ee/ci/yaml/README.html#cache
cache:
  paths:
    - ./assistant/node_modules/

dev:
  stage: dev
  script:
    - cd assistant/
    - npm set cache .npm
    - npm test
    - jovo build --stage dev -p alexaSkill
    - jovo deploy --stage dev --target lambda -p alexaSkill
    - jovo deploy --stage dev -p alexaSkill --ask-profile __ENVIRONMENT_ASK_PROFILE__
    - jovo build --stage dev -p googleAction
    - jovo deploy --stage dev -p googleAction
test:
  stage: test
  only:
    refs:
      - test
  script:
    - cd assistant/
    - npm set cache .npm
    - npm test
    - jovo build --stage test -p alexaSkill
    - jovo deploy --stage test --target lambda -p alexaSkill
    - jovo deploy --stage test -p alexaSkill --ask-profile __ENVIRONMENT_ASK_PROFILE__

production:
  stage: production
  only:
    refs:
      - master
  script:
    - cd assistant/
    - npm set cache .npm
    - npm test
    - jovo build --stage production -p alexaSkill
    - jovo deploy --stage production --target lambda -p alexaSkill
    - jovo deploy --stage production -p alexaSkill --ask-profile __ENVIRONMENT_ASK_PROFILE__