# GET https://api.github.com/user: 401 - Bad credentials

**URL:** <https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424>\
**Category:** Travis CI Discussions & Feedback\
**Created:** [March 3, 2020, 6:11am UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424 "2020-03-03T06:11:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lindsayrutter](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@lindsayrutter](https://travis-ci.community/u/lindsayrutter)\
**Post date:** [March 3, 2020, 6:11am UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/1 "2020-03-03T06:11:18Z")

</div>

I have been connecting Travis CI to build automatically in one of my GitHub repos. Currently, my [Travis CI build is successful.](https://travis-ci.com/lindsayrutter/ggenealogy/builds/151484139) However, I notice the following message in that succesful build:

`Skipping a deployment with the releases provider because this repo's name does not match one specified in .travis.yml's deploy.on.repo: HughParsonage/latex-travis`

I suspect this is because I followed an example `.travis.yml` online and so the deployed repo is still pointing to another repository (`HughParsonage/latex-travis`). So, I simply changed the last line of [my `.travis.yml file`](https://github.com/lindsayrutter/ggenealogy/blob/master/.travis.yml) to deploy the repo to the my intended GitHub repo [(lindsayrutter/ggenealogy).](https://github.com/lindsayrutter/ggenealogy) Doing so then caused my [Travis CI build to fail](https://travis-ci.org/lindsayrutter/ggenealogy/builds/657593197?utm_source=github_status&utm_medium=notification) with the following message:

`GET https://api.github.com/user: 401 - Bad credentials`

For the time being, I switched the last line of [my `.travis.yml file`](https://github.com/lindsayrutter/ggenealogy/blob/master/.travis.yml) to point to the unrelated GitHub repo just so the build will pass. However, I assume I should eventually have this last line pointed to the correct repo (lindsayrutter/ggenealogy).

I should state that the repository used to be called lrutter/ggenealogy. However, I feel I have updated this thoroughly. Upon Internet search, I see similar problems [here](https://travis-ci.com/bash/rustfmt/jobs/213178499) and [there](https://travis-ci.com/cclauss/LaZagne/jobs/205045973), and only one [GitHub issues forum](https://github.com/mauroc/squiddio_pi/issues/77) with this topic but I am not understanding the suggestions and many of the links are broken.

**How should I attempt to fix the error above when pointed to my repository?** Thank you for sharing ideas.

---

<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:** [March 3, 2020, 1:19pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/2 "2020-03-03T13:19:11Z")

</div>

> <https://github.com/lindsayrutter/ggenealogy/blob/b7042b938fc555e388538e31e373b837aa84bf54/.travis.yml#L22>

[GitHub Releases Uploading - Travis CI](https://docs.travis-ci.com/user/deployment/releases) shows you how to generate the encrypted string for your GitHub API key that is suitable for your deployment. (You may also opt in to testing the next-generation deployment too. See [Deployment (v2) - Travis CI](https://docs.travis-ci.com/user/deployment-v2) .)

> [@lindsayrutter](#):
>
> I should state that the repository used to be called lrutter/ggenealogy.

If you remove it, it would be assumed “this repo”, so explicitly specifying it is for explicitly preventing others (forks) from triggering deployment.

---

<div class="post-metadata">

**Author:** ![lindsayrutter](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@lindsayrutter](https://travis-ci.community/u/lindsayrutter)\
**Post date:** [March 3, 2020, 2:52pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/3 "2020-03-03T14:52:23Z")

</div>

Hello @BanzaiMan. Thank you for your help. I tried your suggestion (creating a GitHub API key) following the instructions on [the site](https://docs.travis-ci.com/user/deployment/releases) you recommended and using the command `travis setup releases --force`.

Indeed, this seemed to rewrite the `api_key secure` field in [my .travis.yml file](https://github.com/lindsayrutter/ggenealogy/blob/e7a9800dc37925a31a5f0b5777b76078e3dc50c5/.travis.yml). Unfortunately, upon submitting this change to GitHub, I still receive the error on my Travis CI Build:

`/home/travis/.rvm/gems/ruby-2.4.5/gems/octokit-4.6.2/lib/octokit/response/raise_error.rb:16:in 'on_complete': GET https://api.github.com/user: 401 - Bad credentials` as seen [here](https://travis-ci.com/lindsayrutter/ggenealogy/builds/151555070).

However, the other aspect of my travis build (`"continuous-integration/travis-ci/push"`) succeeded as seen [here](https://travis-ci.org/lindsayrutter/ggenealogy/builds/657769342?utm_source=github_status&utm_medium=notification).

In case it is related, I was also unsure what to use for my deploy file in my [.travis.yml](https://github.com/lindsayrutter/ggenealogy/blob/e7a9800dc37925a31a5f0b5777b76078e3dc50c5/.travis.yml) file. I currently just typed in the field as “.travis.yml”.

It seems my travis build is half working now. I am using travis CI because I am resubmitting this package to CRAN and was asked to check that it passed on Linux. So, I assume this error on my Travis CI Branch still needs to be fixed. **I am not sure what may be the issue for this error still remaining? Do you have any suggestions on things I should check for?** Thank you again for sharing your advice.

---

<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:** [March 3, 2020, 3:13pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/4 "2020-03-03T15:13:13Z")

</div>

OK. I see the problem now. You have enabled your builds on both [travis-ci.org](http://travis-ci.org) ([https://travis-ci.org/lindsayrutter/ggenealogy/builds?utm\_medium=notification&utm\_source=github\_status](https://travis-ci.org/lindsayrutter/ggenealogy/builds?utm_medium=notification&utm_source=github_status)) and [travis-ci.com](http://travis-ci.com) ([https://travis-ci.com/lindsayrutter/ggenealogy/builds/](https://travis-ci.com/lindsayrutter/ggenealogy/builds/)) with GitHub Apps. The CLI commands work with the .org API endpoint by default, so the data you have is valid for .org but not .com.

I suggest disabling .org, and use the GitHub Apps going forward. See [https://docs.travis-ci.com/user/deployment/releases#using-travis-ci-client-to-populate-initial-deployment-configuration](https://docs.travis-ci.com/user/deployment/releases#using-travis-ci-client-to-populate-initial-deployment-configuration).

* * *

An aside: GitHub Releases generally works with tags, so you’d want to make sure that this would fit your workflow. [https://travis-ci.org/lindsayrutter/ggenealogy/builds/657769342?utm\_medium=notification&utm\_source=github\_status](https://travis-ci.org/lindsayrutter/ggenealogy/builds/657769342?utm_medium=notification&utm_source=github_status) succeeded, but it was triggered by a non-tag build, and GitHub created a release with a randomized name [https://github.com/lindsayrutter/ggenealogy/releases/tag/untagged-b6de7df81029a5788ce3](https://github.com/lindsayrutter/ggenealogy/releases/tag/untagged-b6de7df81029a5788ce3).

---

<div class="post-metadata">

**Author:** ![lindsayrutter](https://avatars.discourse-cdn.com/v4/letter/l/7cd45c/32.png) [@lindsayrutter](https://travis-ci.community/u/lindsayrutter)\
**Post date:** [March 3, 2020, 4:16pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/5 "2020-03-03T16:16:31Z")

</div>

Hello @BanzaiMan. Thanks for the suggestion to [use the Travis CI command line client to configure the .travis.yml file](https://docs.travis-ci.com/user/deployment/releases#using-travis-ci-client-to-populate-initial-deployment-configuration). I tried now issuing the command:

`travis setup releases --com --force`

This process did seem to change my api\_key in my .travis.yml file. I am now receiving the opposite problem upon pushing to GitHub. That is, my “Travis CI Build” is successful, but my “continuous-integration/travis-ci/push” is unsuccessful as seen [here](https://github.com/lindsayrutter/ggenealogy/commits/master).

I am not sure if this is what you suggested to do to at least get rid of the error? Or, **is there a specific procedure to “disable .org” as you suggested?** (besides running --com option in travis setup). Thank you very much again for your help.

---

<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:** [March 3, 2020, 4:25pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/6 "2020-03-03T16:25:20Z")

</div>

> [@lindsayrutter](#):
>
> is there a specific procedure to “disable .org” as you suggested?

Go to [Travis CI - Test and Deploy with Confidence](https://travis-ci.org/account/repositories), and find your repo there.

---

<div class="post-metadata">

**Author:** ![Ruskab](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/ruskab/32/3952_2.png) [@Ruskab](https://travis-ci.community/u/Ruskab)\
**Post date:** [March 3, 2020, 9:53pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/7 "2020-03-03T21:53:18Z")

</div>

I had a similar problem at the deploy process to heroku provider:

`API request failed. Message: Invalid credentials provided.`

Until now, I had configured HEROKU Environment Variable in Travis panel with heroku api key, and I used it in my travis.yml to configure the deploy.

```
deploy:
  provider: heroku
  api_key:
    secure: $HEROKU
...

```

At march 2 I started to have this error, the only thing that worked for we was, install travis cli, encrypt the heroku api-key and add it encrypted to my travis.yml

`travis encrypt <api_key> --add deploy.api_key`

```
deploy:
  provider: heroku
  api_key:
    secure: encypted_key...
...

```

Is it no longer possible to use environment variables to have credentials hidden there?

---

<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:** [March 3, 2020, 10:26pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/8 "2020-03-03T22:26:57Z")

</div>

Was your `$HEROKU` value plain, or encrypted? If it was plain and if it was working, it seems accidental; we would not have had access to `$HEROKU` value when configuring the build, and it was working because we passed through `secure` value without validation (it should be decrypted before it’s passed on to the next component in the system).

It stopped working because we are now doing more to ensure that configuration is correct and workable:

> **[Travis CI Documentation](https://docs.travis-ci.com/user/build-config-validation)**
>
> Build Config Validation

  

> **[The Travis CI Blog: Build Config Validation now in beta](https://blog.travis-ci.com/2019-10-24-build-config-validation)**
>
> We are excited to announce the new Build Config Validation feature. It is now
> in beta, and available for you to activate.
> 
> When active, the build config validation
> feature will validate and normali...

And your new configuration works, because it is valid. (I’d think that `api_key: $HEROKU` key-value pair should have worked, but I’m saying this from memory.)

---

<div class="post-metadata">

**Author:** ![LeeRayno](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/leerayno/32/6989_2.png) [@LeeRayno](https://travis-ci.community/u/LeeRayno)\
**Post date:** [August 14, 2021, 3:39pm UTC](https://travis-ci.community/t/get-https-api-github-com-user-401-bad-credentials/7424/9 "2021-08-14T15:39:31Z")

</div>

the same issue build with [travis-ci.com](http://travis-ci.com)  
`gh-token is invalid. Details: GET https://api.github.com/user: 401 - Bad credentials // See: https://docs.github.com/rest`

and my travis.yml config

```auto
language: node_js
node_js:
  - lts/*
script:
  - npm run docs:build
deploy:
  provider: pages
  skip-cleanup: true
  local_dir: docs/.vuepress/dist
  github-token: $GITHUB_TOKEN
  keep-history: true
  on:
    branch: master

```

On .com the builds log URL [Travis CI - Test and Deploy with Confidence](https://travis-ci.com/github/LeeRayno/Blog/builds/235341555)
