Hiding private details from open source projects

后端 未结 4 506
轻奢々
轻奢々 2021-02-11 07:39

I have a .net github project that is basically a wrapper around a web API. In the test project, I am calling to the API using an API key. I need to keep this key private, how do

4条回答
  •  北荒
    北荒 (楼主)
    2021-02-11 08:07

    You are probably looking for the App.config file for a project. It will be copied to .exe.config when you compile it. Users can edit that config file as needed.

    In that config file, you can add your API keys:

    
        
            
        
    
    

    Then you can access it from your code using ConfigurationManager.AppSettings:

    string apiKey = ConfigurationManager.AppSettings["APIKey"];
    

提交回复
热议问题