How can I hide my API Keys
stored in appsettings.json
as I initialize in Git
?
CodePudding user response:
You need to implement config. files. You will have a web.config file in your project and in this one you put the following inside < configuration >:
<appSettings file="hiddenappsettings.config"></appSettings>
Then you create a hiddenappsettings.config file and you do the following:
<appSettings>
<add key="APIKey" value="YourApiKeyValue" />
</appSettings>
To acces you will need to use Configuration Manager to access to that key
CodePudding user response:
@Leandro thank you for the suggestion. I however figured out secrets.json
is a safer place to host the secrets securely (though locally) and that fixed my problem.