针对 google 智能家居令牌交换问题采取的行动
Action on google Smart home token exchange problem
我卡住了。
情况:
我们在移动应用 IOS/Android 中使用 Firebase 身份验证,并在 Google(智能家居)上使用 Action。
同时我们使用 Firebase Function 来处理请求。
问题:
google 上的操作帐户链接是我的问题。
但是我的身份验证 URL 工作完美并且能够成功发回数据。
但是当它调用 token url 时,我们就遇到了问题。
因为,我说过我们使用 Firebase 身份验证,我们不知道如何从 Firebase 获取访问令牌和刷新令牌以发送回 Google 主页。
下面是我的令牌代码,我现在只是发送常量令牌,我不知道如何获得访问令牌,请帮助,我真的很感激你。
令牌URL Firebase 函数:
export const token = functions.https.onRequest(async (request, response) => {
//admin.auth().getUser(response)
const grantType = request.query.grant_type ?
request.query.grant_type : request.body.grant_type;
const secondsInDay = 86400; // 60 * 60 * 24
const HTTP_STATUS_OK = 200;
console.log(`Grant type ${grantType}`);
const user = admin.auth().getUser(request.body.code);
user.getIdToken(true).then(function(idToken) {
}).catch(function(error) {
});
console.log(request.body.client_id);
console.log('test');
console.log(request.body.client_secret);
let obj = {};
if (grantType === 'authorization_code') {
obj = {
token_type: 'bearer',
access_token: 'jkljkhasdjhjhkdhasdsd',
refresh_token: 'nkjcajkguiahdilawjd,bcjkbakdjhdlasd',
expires_in: secondsInDay,
};
} else if (grantType === 'refresh_token') {
obj = {
token_type: 'bearer',
access_token: 'njkhasiumnabkdukchaskjhkhad',
expires_in: secondsInDay,
};
}
response.status(HTTP_STATUS_OK)
.json(obj);
});
we use Firebase Authentication, we don't know how to fetch Access token and Refresh token from Firebase to send back to Google Home.
Firebase 身份验证不会直接将功能公开给 mint 并为用户验证 OAuth 令牌,它只是让您能够提供客户端用户登录和验证。您需要在 Firebase 身份验证之上实施您自己的 OAuth 令牌管理。
我们有一个 example app that does something similar which you might find helpful, and a companion blog post 描述了一些实施细节。该示例使用 JWT 对 Firebase 身份验证用户数据进行编码,因此每个请求都可以确定如何将智能助理意图映射到 Firebase uid
值。
我卡住了。
情况:
我们在移动应用 IOS/Android 中使用 Firebase 身份验证,并在 Google(智能家居)上使用 Action。 同时我们使用 Firebase Function 来处理请求。
问题:
google 上的操作帐户链接是我的问题。 但是我的身份验证 URL 工作完美并且能够成功发回数据。 但是当它调用 token url 时,我们就遇到了问题。
因为,我说过我们使用 Firebase 身份验证,我们不知道如何从 Firebase 获取访问令牌和刷新令牌以发送回 Google 主页。
下面是我的令牌代码,我现在只是发送常量令牌,我不知道如何获得访问令牌,请帮助,我真的很感激你。
令牌URL Firebase 函数:
export const token = functions.https.onRequest(async (request, response) => {
//admin.auth().getUser(response)
const grantType = request.query.grant_type ?
request.query.grant_type : request.body.grant_type;
const secondsInDay = 86400; // 60 * 60 * 24
const HTTP_STATUS_OK = 200;
console.log(`Grant type ${grantType}`);
const user = admin.auth().getUser(request.body.code);
user.getIdToken(true).then(function(idToken) {
}).catch(function(error) {
});
console.log(request.body.client_id);
console.log('test');
console.log(request.body.client_secret);
let obj = {};
if (grantType === 'authorization_code') {
obj = {
token_type: 'bearer',
access_token: 'jkljkhasdjhjhkdhasdsd',
refresh_token: 'nkjcajkguiahdilawjd,bcjkbakdjhdlasd',
expires_in: secondsInDay,
};
} else if (grantType === 'refresh_token') {
obj = {
token_type: 'bearer',
access_token: 'njkhasiumnabkdukchaskjhkhad',
expires_in: secondsInDay,
};
}
response.status(HTTP_STATUS_OK)
.json(obj);
});
we use Firebase Authentication, we don't know how to fetch Access token and Refresh token from Firebase to send back to Google Home.
Firebase 身份验证不会直接将功能公开给 mint 并为用户验证 OAuth 令牌,它只是让您能够提供客户端用户登录和验证。您需要在 Firebase 身份验证之上实施您自己的 OAuth 令牌管理。
我们有一个 example app that does something similar which you might find helpful, and a companion blog post 描述了一些实施细节。该示例使用 JWT 对 Firebase 身份验证用户数据进行编码,因此每个请求都可以确定如何将智能助理意图映射到 Firebase uid
值。