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.)

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

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波