duan198299 2010-07-19 20:28
浏览 34
已采纳

安全地将api密钥从远程服务器传递到身份验证页面

This is my first time building an authenticated API and I'm running into a few roadblocks.

How do I securely pass an API key from the remote client's page to my server (for the user to authenticate connecting his account to the client's page/app)?

-dylan

  • 写回答

2条回答 默认 最新

  • douhulao7642 2010-07-19 20:35
    关注

    In my experience, API Keys are actually used as salt to hashes, and the key itself is not actually passed.

    When a client generates a request to the server, it hashes a bunch of stuff together (request time, user_id) + the hash, and the hash is included in the request. On the server side, the same hash is recalculated based by retrieving the key for the server, and following the same steps. If the hash doesn't match, it means that client making requests to the server doesn't know 1) the steps to create the hash, and more importantly 2) the API key used as the salt to create the hash. In this way you can determine your client does in fact have the key, and that they know how to authenticate, all without sending the actual API Key.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?