How do I secure REST API calls?

前端 未结 6 1082
南旧
南旧 2020-11-29 15:51

I\'m developing the restful web app that using some popular web framework on the backend, say (rails, sinatra, flask, express.js). Ideally, I want to develop client side wit

6条回答
  •  青春惊慌失措
    2020-11-29 16:28

    Here's what I do:

    1. Secure the API with an HTTP Header with calls such as X-APITOKEN:

    2. Use session variables in PHP. Have a login system in place and save the user token in session variables.

    3. Call JS code with Ajax to PHP and use the session variable with curl to call the API. That way, if the session variable is not set, it won't call and the PHP code contains the Access Token to the API.

提交回复
热议问题