firebase - 关于谷歌智能家居令牌交换问题的行动
问题描述
我陷入了困境。
情况:
我们在移动应用 IOS/Android 和 Action On Google(智能家居)中使用 Firebase 身份验证。我们使用 Firebase 函数来处理请求。
问题:
在 google 上操作的帐户链接是我的问题。但是我的身份验证 URL 可以完美运行,并且能够成功发回数据。但是当它调用令牌 url 时,我们会在这里遇到问题。
正如我所说,我们使用 Firebase 身份验证,我们不知道如何从 Firebase 获取访问令牌和刷新令牌以发送回 Google Home。
下面是我的令牌代码,我现在只是发送常量令牌,我不知道如何获得访问令牌,请帮助,我真的很感谢你。
令牌 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);
});
解决方案
推荐阅读
- angularjs - AngularJS 模块 + Webpack + ES6 导入 - 依赖注入和连接顺序问题
- html - 在树莓派上的 lighttpd Web 服务器中通过 /var/www/cgi-bin 运行 .cgi 脚本
- c++ - 如何获得进程的整数PID?
- r - 将经度和纬度投影到平面坐标系
- xamarin - 将 Xamarin.Forms 项目从 4.2x 更新到 4.4 后如何修复 Java.Lang.ClassNotFoundException?
- javascript - 重新排序某些元素后如何重置 ng-repeat 块?
- sql - 在 Oracle (Column_A,Column_B) IN (M,M) 中将 IN 与多个值一起使用
- node.js - 当接受预订状态时,我如何重定向指令?暮光之城
- css - 删除过滤器模糊css周围的暗边框
- excel - 将筛选视图从 PowerPivot 导出到 Excel