douliaopan1419 2015-11-04 17:09
浏览 14
已采纳

在源代码中避免使用OAuth令牌?

I have to use my OAuth2 token in my API program.
But I also want to share my code via GitHub.
How can I use my secret token without having it in my source?

  • 写回答

1条回答 默认 最新

  • duanlei20082008 2015-11-04 21:12
    关注

    You could require the token as a runtime argument for the application or you could store the token in a file that is not added to the repository.

    For a file, you could store the API token in token.txt and then add token.txt to your .gitignore

    This way you can have people who want to use your project just include their own API tokens without having to modify the code!

    (If you're trying to hide or obfuscate your own token, that will probably be more effort than it's worth.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致