我正在构建一个Vue js Web应用程序,我想分别调用我的棱形存储库,但是我不知道如何在不暴露访问令牌的情况下进行操作.我正在此处. 有任何想法吗?
I'm building a vue js web app and I would like to make respective calls to the to my prismic repo, but I don't know how to do it without exposing my access token. I am using the rest api approach shown here. Any ideas?
http请求的语法如下.我想在我的Vue组件中执行此操作,而又不暴露access_token.
The http request syntax is as follows. I want to do this inside my vue components while not exposing the access_token.
您的- repository-name.prismic.io/api/v2/documents/search?ref=Your_Ref&access_token=Your_Token
在我的API/安全性设置中,我还获得了一个客户端ID和客户端密钥.我也不知道如何使用它们.
In my API/Security settings I'm also given a Client ID and Client Secret. I can't figure out how I can use these either.
谢谢
推荐答案您必须将访问令牌存储在服务器上,并使其代表客户端处理请求.
You'd have to store your access token on your server and make it process the requests on behalf of the client.
最后,您将请求发送到服务器,而不是直接发送到prismic.io,然后服务器将发送访问令牌授权请求,获取所需内容,然后将其返回以响应客户端.
In the end, you'd send requests to your server instead of directly to prismic.io, your server will then send the access token authorized request, fetch whatever you need and return it back in response to the client.
工作流程如下:
如果要在客户端隐藏访问令牌,则不可能.为了保护您的访问令牌,其他两个选项是:
If you want to hide your access token client-side, then it's impossible. To protect your access token the other two options are:
上面的两个选项可能不是您想要的,因此只剩下设置代理服务器了.
The two options above are probably not what you want, so setting up a proxy server is what's left.
更多推荐
Prismic
发布评论