japaric / trust

Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows
Apache License 2.0
1.26k stars 59 forks source link

401 - Bad credentials Travis #104

Open flofriday opened 6 years ago

flofriday commented 6 years ago

I don't like writing an issue here and bore you but I spend the whole day with 22 releases and everyone failed. I simply don't know what to do at this point.

What I did

  1. copy the trust files in my repository https://github.com/flofriday/thumbcloud
  2. changing some build options
  3. create the appveyor encrypted key with my github token -> and appveyor works perfectly which means my github token must work
  4. create the travis encrypted key with travis encrypt bd2XXXXXXX46f -> travis fails everytime at deployment with GET https://api.github.com/user: 401 - Bad credentials https://travis-ci.com/flofriday/thumbcloud/jobs/128447592

I also tried:

flofriday commented 6 years ago

It took me 27 releases but I got it.

I had to type travis encrypt bd2XXXXXX46f --pro (bd2XXXXXX46f is my github token).

Little bit of backstory:

Originally travis was split in travis-ci.org for opensource and travis-ci.com for paid private project. However in may 2018 they decided to move to travis.com only. So when I signed up to travis I got an travis-ci.com account, but the commandline tool https://github.com/travis-ci/travis.rb was last updated in march and so it doesn't know that the two domains are now united.

Therefore, the tool assumed that my opensource project is on .org which is wrong and with travis encrypt --pro you can force the .com domain.

However, I am not sure if this is the reason it didn't worked, it is just the only explanation I can think of. Please correct me if I am wrong.

Add this to .travis.yml

Maybe it would be a good idea to add to .travis.yml something like:

deploy:
  # TODO update `api_key.secure`
  # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new
  # - Encrypt it: `travis encrypt 0123456789012345678901234567890123456789`
  #      Note: If your project is on travis-ci.com you need to add the --pro flag like so:
  #      `travis encrypt 0123456789012345678901234567890123456789 --pro`
  # - Paste the output down here
  api_key:
psychelzh commented 6 years ago

@flofriday Thanks! It solved my issue, too. This could be added to the documentation of travis-ci or to StackOverflow for future reference.

psychelzh commented 6 years ago

Now I understand it. We should choose --org or --pro (travis.com) at first. Based on the full conversion from org to com, so I used --pro. I manually turned off the services of org, then the releases never result in a bad credential now.

flofriday commented 6 years ago

Yeah the option with --pro solves it.

I will write a PR to make the documation more clearly about this difference.

psychelzh commented 6 years ago

@flofriday Maybe this doc would help a little. Seemingly there will be a full transit from org to pro.

flofriday commented 6 years ago

I created the PR #105, and I will leave this issue open for now until the problem is fixed, so future users can find the solution faster.

@psychelzh yes if found the document helped once I found out that --pro fixed my problem, but until that moment it wasn't clear to me that my problem and the transit where connected. As the doc points out the decision for the transit took place on May 2nd, 2018 however the CLI travis tool was last updated on February 12, 2018 (as you can see here. So the tool just doesn't know about this move to travis-ci.com. Personally I really hope that they will update their tool so it can auto-detect between .com and .org.

srianbury commented 4 years ago

Just had this issue and had the wrong permission on my personal token. It's successfully building with these permissions: user:email, read:org, repo_deployment, repo:status, write:repo_hook and I added repo_public because mine is a public repo.

source