问题描述
我正在使用 firebase google auth 来管理用户。此外,我必须使用日历 API 集成用户日历,现在 firebase auth 提供 ID 令牌、ID 刷新令牌和 oAuth 令牌 but not oAuth refresh token,因此我必须使用 { 获取 oAuth 令牌和 oAuth 刷新令牌{3}},现在我明白了,但是有没有办法使用这些令牌来创建 firebase auth 用户?我知道有使用 import numpy as np
A = np.array([1.0,-.75,.25])
yc = -2 * np.ones(45)
y = np.zeros(6)
u = np.zeros(6)
col = A.size
alpha = np.array([1,A[1] - 1])
if col > 2:
for i in range(2,col):
alpha = np.append(alpha,A[i] - A[i-1])
alpha = np.append(alpha,-A[col-1])
创建登录的方法,但这需要 ID 令牌而不是 oAauth 令牌。
更新
signInWithCredential
在 gAPI 登录后,我收到以下详细信息:
const { client_secret,client_id,redirect_uris } = credentials.web;
const oauth2client = new google.auth.OAuth2(client_id,client_secret,redirect_uris[0]);
const authUrl = oauth2client.generateAuthUrl({
access_type: 'offline',scope: ScopES,});
// Get code from the URL
oauth2client.getToken(code,(err,token) => {
oauth2client.setCredentials(token);
});
解决方法
要访问 ID 令牌,您必须向 GAPI OAuth 请求添加额外的范围。与您的日历范围一起添加“openid”。然后在令牌响应中,您应该可以访问 id_token
。
此外,您可以跳过上述步骤,将来自 google 的 OAuth 令牌与 firebase 交换以获取 firebase ID 令牌。
官方文档:https://firebase.google.com/docs/reference/rest/auth/#section-sign-in-with-oauth-credential