gpt4 book ai didi

google-chrome-extension - chrome 扩展需要从服务器端离线访问

转载 作者:行者123 更新时间:2023-12-04 18:00:04 26 4
gpt4 key购买 nike

我正在构建一个 chrome 扩展。我使用 chrome.identity.getAuthToken 获取 access_token。这为我提供了客户端(浏览器)的 access_token。现在我想将此 access_token 传递到我的服务器。我想离线访问已授予的 API,据我所知,为此我必须将其与长期 token 和刷新 token 进行交换。有没有安全的方法将 access_token 传递给服务器?还是应该使用 http post?

另一种方法是将用户重定向到服务器,让两者都在那里。

什么是最好和最安全的做法?

最佳答案

我认为服务器端流程最好使用 authorization_code 流程获取 refresh_token。

使用客户端流程您无法请求刷新 token ,Google 将拒绝该请求并显示消息access_type offline, not allowed for response type token

一旦您在服务器中安全地获得访问 token 和刷新 token ,您就可以将其发送到 chrome 扩展程序,这样扩展程序就不必在维护 token 方面做任何额外的过程,一旦 token 过期,您就可以向服务器请求新的访问 token ,然后服务器将使用刷新 token 刷新访问 token 并发送回扩展

关于google-chrome-extension - chrome 扩展需要从服务器端离线访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36677386/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com