# Failed to deploy (heroku): "API request failed. Message: Invalid credentials provided."

**URL:** <https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988>\
**Category:** Deployment\
**Tags:** dpl-heroku\
**Created:** [September 24, 2020, 1:14pm UTC](https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988 "2020-09-24T13:14:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devellopah](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/devellopah/32/5229_2.png) [@devellopah](https://travis-ci.community/u/devellopah)\
**Post date:** [September 24, 2020, 1:14pm UTC](https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988/1 "2020-09-24T13:14:33Z")

</div>

This is what i got

```auto
Installing deploy dependencies
Fetching dpl-heroku-1.10.15.gem
Fetching multipart-post-2.1.1.gem
Fetching faraday-1.0.1.gem
Fetching rendezvous-0.1.3.gem
Fetching netrc-0.11.0.gem
Successfully installed multipart-post-2.1.1
Successfully installed faraday-1.0.1
Successfully installed rendezvous-0.1.3
Successfully installed netrc-0.11.0
Successfully installed dpl-heroku-1.10.15
5 gems installed
dpl.2
Preparing deploy
No stash entries found.
API request failed.
Message: Invalid credentials provided.
Reference: 
failed to deploy

```

My travis config

```auto
language: node_js
node_js:
  - 12
branches:
  only:
    - master
deploy:
  provider: heroku
  app: my-react-burger
  api_key:
    secure: $HEROKU_API_KEY
after_success:
  - cat ./coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js
  - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

```

Please help to figure out the issue.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [September 24, 2020, 4:15pm UTC](https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988/2 "2020-09-24T16:15:25Z")

</div>

How is `$HEROKU_API_KEY` defined? If it’s in the settings as a private variable, there is no need for the `secure:` key in `.travis.yml`.

---

<div class="post-metadata">

**Author:** ![devellopah](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/devellopah/32/5229_2.png) [@devellopah](https://travis-ci.community/u/devellopah)\
**Post date:** [September 24, 2020, 7:09pm UTC](https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988/3 "2020-09-24T19:09:28Z")

</div>

I have defined it in _Settings -\> Enviroment variables_  
Should i change my travis config?

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [September 25, 2020, 1:55pm UTC](https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988/4 "2020-09-25T13:55:45Z")

</div>

> [@devellopah](#):
>
> Should i change my travis config?

Yes. `secure: ENCRYPTED_STRING` is for the cases where `ENCRYPTED_STRING` is included in `.travis.yml`.

---

<div class="post-metadata">

**Author:** ![devellopah](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/devellopah/32/5229_2.png) [@devellopah](https://travis-ci.community/u/devellopah)\
**Post date:** [September 25, 2020, 2:20pm UTC](https://travis-ci.community/t/failed-to-deploy-heroku-api-request-failed-message-invalid-credentials-provided/9988/5 "2020-09-25T14:20:57Z")

</div>

Thanks a lot, you’ve made my day 😃

I have replaced

```auto
  api_key:
    secure: $HEROKU_API_KEY

```

to

```auto
  api_key: $HEROKU_API_KEY

```

and it deploys successfully now!
