HACS: How do I replace my existing personal access token with a new one?

I already have HACS installed and up and running with addons, cards, etc. If I need to replace the Github personal access token with a new one, how do I do this without losing all my HACS addons?

Can I just delete the existing personal access token on the github page for HACS… and, HomeAssistant will be smart enough to prompt me to enter a new token? Or, would I just end up destroying my HACS setup?

3 Likes

You do not want to just delete your current access token. Neither HA nor HACS will prompt you to enter a new one and it could cause boot issues with HA. I believe what you want to do is go to the Configuration/Integrations ui remove the HACS integration (in the three dot menu) and then add it back at which point you will be asked for your new token. I don’t know whether your current setup will be retained, I suspect not, so note the current addons, cards, etc. before hand and re-add them afterwards.

3 Likes

Sorry to revive this old thread, but it’s right on point. I am being prompted to regenerate my Github token to take advantage of the new formats. Will removing and reinstalling HACS wipe out my custom integrations? If so, I’m going to hold off on doing this as long as possible.

5 Likes

I just uninstalled HACS to re-install it and now I can’t get into my UI past a sidebar and a blank lovelace default page.

How do we make this process more intuitive and fix the problem?

I was in the same boat and decided to try it out. I was able to remove the HACS integration from HA (Configuration > Integrations > 3 dots on HACS card > Delete), and then I promptly added it right back - I did not restart in between those steps - and it configured using OAuth access now instead of PAT.

It retained all the rest of my configuration.

9 Likes

I did a snapshot/backup to be safe, but I did delete the HACS integration via Configuration -> Integrations, then restarted HA to fully remove it. Once removed, I added it back using the menus in Configuration -> Integrations and everything appears to be functional afterwards. I’m assuming it is using the new access token format as a part of the new setup. Cheers and good luck!

1 Like

Thanks for sharing your experience. I assume your post was prompted by the Github announcement email, as others above have mentioned. Given the breadth of HACS users affected, I too hope the devs find a way to update/replace the token without the risk of removal and reinstallation or confirm that it’s generally safe to do without breaking (assuming your case was an anomaly). Until then, I’m going to hold off on any action as it seems the old format will continue to work for now.

2 Likes

Now I only see 404 error when attempting to access with public or private url.

Okay, I’m seeing this when I tail -f home-assistant.log

2021-04-05 20:28:59 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"

If you used the Oauth then you don’t need to do anything. If you used YAML for HACS just make a new token and edit the yaml with the new creds. You should not need to remove or reinstall anything

When you say that everything appears to be functional afterwards, do you mean all your HACS addons you had installed previously (frontend cards, etc./integrations) were restored after you uninstalled/reinstalled the HACS integration? I have several HACS addons currently.

I’ve generated the new token but as of now I’ve not done any action an HA/Hacs configuration. Hope it will clear out soon how to proceed to safely change the installed token without any risk of loosing what was working fine before the token update. I’ll keep an eye on this issue meanwhile.

You could try searching for the old token in .storage files and then editing/replacing

It’s been a while since I installed HACS, so I don’t recall the Oath screens specifically, but I also don’t see any hacs section in my YAML files so I guess it must have been Oath.

When you say I don’t need to do anything, does that mean HACS will automatically request a new format token or that I should already be using a new token since I used Oauth? If the latter, I wonder then why Github sent the warning about the old format token.

No until recently it prompted for the token

I was thinking exactly this, so I just tried it.

I took the following steps:

  • Deleted the old token on Github
  • Generated a new token
  • Stopped my HA Core docker container
  • Edited the “core.config_entries” file with the newly generated token
  • Restarted my HA Core docker container

Seems to work like a charm. No errors related to HACS in the log files and I can navigate the repo’s.

10 Likes

You could also choose to regenerate the token when open it in Github.

this worked for me as well.

I did try to regenerate mine but in the end had to just create a new one. (Non HACS as I switched to Oauth for that way back)

Thanks for the directions. This worked well for me.
I deleted HACS from my integrations and re-added it without restarting HA. All HACS components are back and working.

1 Like

Did the following:

  • Generated a new token on GitHub (didn’t want to be destructive)
  • Replaced API token for HACS in core.config_entries
  • Restarted
  • Deleted old token form GitHub
  • Restarted

Not seeing any errors, been able to update HACS components and everything seems to be functions as expected.

3 Likes