[英]Refresh token for Google OAuth 2.0
I have an application that uses Google APIs in some places, and I want to avoid having the user login every time.我有一个在某些地方使用 Google API 的应用程序,我想避免让用户每次都登录。 Currently, I only receive a Google access token in the response, not a refresh token.目前,我仅在响应中收到 Google 访问令牌,而不是刷新令牌。 How can I obtain the refresh token?如何获取刷新令牌?
This is the function I use to when the user click to login with google:这是我在用户点击使用 google 登录时使用的 function:
authenticate() {
const client = google.accounts.oauth2.initTokenClient({
client_id: 'MY_CLIENT_ID',
scope: [
"All_NECESSARY_SCOPES",
].join(" "),
callback: (res) => {
this.accessToken = res.access_token
this.loadClient()
}
})
client.requestAccessToken()
},
It works for getting the access token.它适用于获取访问令牌。 And I need the refresh token, Please Help Me:)我需要刷新令牌,请帮助我:)
Client side JavaScript does not return a refresh token.客户端 JavaScript 不返回刷新令牌。 It would be a security risk.这将是一个安全风险。
If you want a refresh token you need to use a server sided language like Node.js如果你想要一个刷新令牌,你需要使用像 Node.js 这样的服务器端语言
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.