is there a way to update login credentials, either the token or password, programmatically? I don’t want to need to manually log in sonarqube web console to create a new token or change the password.
Yes, you can do these things programmatically, via the SonarQube RESTful application programming interface.
The web services composing the web API are documented within SonarQube. Look into the Web APIapi/user_tokens where you will find ways to search, revoke, and generate tokens, and api/users where you will find how to change the password.