gpt4 book ai didi

php - Google Api,当我有访问 token 和以前的刷新 token 时如何刷新用户 token

转载 作者:搜寻专家 更新时间:2023-10-31 21:27:23 24 4
gpt4 key购买 nike

如果我有以前的刷新 token 和使用纯 php 的访问 token ,没有 Google Api 库,是否可以刷新 Google Api token ?我在数据库中存储了许多用户刷新和访问 token 。

我正在使用来自这个地址的 url:

https://developers.google.com/identity/protocols/OAuth2WebServer?hl=en#creatingcred

并使用这个地址:

https://accounts.google.com/o/oauth2/v2/auth?
scope=email%20profile&
state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&
redirect_uri=https%3A%2F%2Foauth2-login-demo.appspot.com%2Fcode&,
response_type=code&
client_id=812741506391.apps.googleusercontent.com

我一直被重定向到某个地方,并且没有获得新的access token。但是,为什么我必须放置 redirect_uri

此外,在我的 Google API 管理器的凭据部分下,我有一些 Client IDClient secret 但是 Client ID 1076711322609-s9mrrfp3t8gto2qkrj4ud3jjhr3rr0ph.apps。 googleusercontent.com 与这个 client_id=812741506391.apps.googleusercontent.com 不同,为什么?

所以问题是,我如何使用用户的访问 token 访问用户 Google API 端点,并使用 PHP(REST 调用)每小时刷新这些 token ,而无需任何提示、登录名和密码。有可能吗?

enter image description here

最佳答案

经过多次尝试,我找到了可行的解决方案。

===编辑====@DaImTo 的回答好多了

发布

https://developers.google.com/oauthplayground/refreshAccessToken

标题:

Content-Type: application/json

正文:

{
"refresh_token": "YOUR_PREVIOUS_REFRESH_TOKEN"
}

关于php - Google Api,当我有访问 token 和以前的刷新 token 时如何刷新用户 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34156199/

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