Secure Your HubSpot CLI with New Global Configuration

Brooke walks through HubSpot CLI's new global configuration system. You can now manage multiple accounts securely, migrate old config files, and use override files to set default accounts in local directories.
Hey, y', all, It's Brooke with HubSpot. Today I'm going to go over our new global configuration system. This new global config was designed to be more secure and easier to debug. Now, instead of having multiple HubSpot config YAML files, you'll have a single config file that will live in a folder at the root of your user computer folder. Then, when you're inside specific local directories and you need to Change the default HubSpot account you're connecting to, you'll create an HS account override file that will only include the HubSpot account ID. It is still best practice to add these to a gitignore file, but if you're working in teams in a private repository and need each user to know which HubSpot account these files are connected to, you can safely commit these without fear of leaking any personal access tokens. So let's go over how to set this up. So right now in my folder, I have the standard HubSpot config YAML file, and it has my account information along with personal access information. And so what we're going to do is use a new command in order to migrate this over to our new system without having to do it ourselves. But first, let's make sure we're using the latest version of the CLI so we can run hs dash dash version and we can see that number. I'm running seven. So let's go ahead and do npm I-ghubspot CLI at latest. And this will go ahead and grab the newest version of the cli. Now that that's installed, we can check the versioning again with HS Dash Dash version. And now we're running the newest 7.4.2. Now let's go ahead and run the migrate command, which is just HS config migrate. And this will say from the deprecated config file to the new global config file, and it'll tell you where it's going to live within your computer file system. And I'm going to go ahead and type Y for yes. And now this HubSpot config file has actually been deleted. So now to check that folder, I'm going to go ahead and go into my finder and then go to users and then go to my name and then we should see it here. But it is a hidden folder. So in order to see a hidden folder on Mac, you're going to use command shift dot and that will go ahead and show you all of the hidden files in this folder. So now we can see our HSCLI hidden folder here and we can see our config YAML file. So we know that it has successfully been created at our root. All right, now let's go back and see how we can add different accounts to this config file. So in that config file we only had one account listed. However, we can continue to add more accounts to our config file and they will all go to the same single config file. So we're going to use the command HS accounts auth and this will go through our auth flow and help us set up our personal access key and everything like that. Once we are here, we can go ahead and choose all of our accounts and then once we've chosen it, we'll click Continue with this account and we'll go ahead and generate the personal access key. We will show and copy it. And now in our terminal we'll go ahead and paste it in and then we're going to give it a unique name. You can keep it as its default just by hitting return. We can also set this account to default. Yes or no? We want to say no. And now we've added that to our config file. Now if you're in a folder and you want to have the default HubSpot account be different from the one that's listed in your config file, this is where you go ahead and add in an HS account file. So to do this we're going to use HS accounts Create override. So here, this is where you can choose from the different accounts that you have in your config file and then you're going to click on it. And then now it creates this HS account file and all that's in this HS account file is the HubSpot account ID, meaning that there is no personal information like your personal access token that could be leaked through an HS account file. And so that's how you use the new global configuration system to create a safe and effective way to connect all of your hostped accounts to your local environment. Make sure to update your cli. Use the hsconfig migrate command to migrate your old HSCONFIG YAML files. Let us know in the comments below what you think about this. Let know me and make sure to like and subscribe to the HubSpot Developers YouTube channel and I will see you all in another video. Bye all. Bye bye.










