Phonegap:验证应用程序而非用户以获得 api 访问权限

Phonegap: Authenticating the app and not the user for api access

我有一个应用程序,我已经为 php 创建了所需的 API 我也可以使用 firebase 创建它。

该应用旨在供技术新手使用。我不需要任何登录验证。

正如我创建的那样 API 任何通过我的代码的人都可以看到 API link 并且可以获得我不想要的数据。

我想要实现的是 API 当请求仅来自我的应用程序时提供数据

我如何在没有任何用户登录的情况下实现这一点?

创建一个访问令牌并将其存储在您的应用程序中,然后在每个 ajax 请求中您将比较令牌,因此如果令牌有效,您将传送内容,否则您将显示错误消息。

正如,raymond Camden 在他的评论中所说:

it is not secure. I can use Remote Debugging to sniff the access token and then use it myself. At the end of the day, there is no way to do what you want 100% securely.