Я успешно развернул свой код node.js в умном доме с помощью Google Actions.
Я добавил устройства умного дома в приложение GoogleHome, и когда я работаю с устройством, я не получаю никаких журналов функций на странице журналов Google Cloud.
Вот часть моего кода, который я использовал для умного дома.
Я использовал как console.log, так и logger.log, и почему операторы печати не отображаются в журналах облака Google страница проводника?
'use strict';
const { onRequest } = require("firebase-functions/v2/https");
const { onValueWritten } = require("firebase-functions/v2/database");
const { smarthome } = require("actions-on-google");
const { google } = require("googleapis");
const { logger } = require("firebase-functions");
const admin = require("firebase-admin");
const axios = require("axios");
const fetch = require("node-fetch");
const util = require("util");
const serviceAccount = require("");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: ""
});
//admin.initializeApp();
const firebaseRef = admin.database().ref('/');
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/homegraph'],
});
const homegraph = google.homegraph({
version: 'v1',
auth: auth,
});
// Hardcoded user ID
const USER_ID = '102';
exports.login = onRequest((req, res) => {
if (req.method === 'GET') {
logger.log('Starting of GET ');
logger.log('Requesting login page');
res.send(`
Link this service to Google
`);
logger.log('%s',req.query.responseurl);
} else if (req.method === 'POST') {
const responseurl = decodeURIComponent(req.body.responseurl);
logger.log('__POST__START_%s',req.body.responseurl);
logger.log(`Redirect to ${responseurl}`);
return res.redirect(responseurl);
} else {
// Unsupported method
res.send(405, 'Method Not Allowed');
}
});
exports.fakeauth = onRequest((request, response) => {
const responseurl = util.format('%s?code=%s&state=%s',
decodeURIComponent(request.query.redirect_uri), 'xxxxxx',
request.query.state);
logger.log(`Set redirect as ${responseurl}`);
logger.log('Ending of FAKEAUTH');
return response.redirect(
`/login?responseurl=${encodeURIComponent(responseurl)}`);
});
exports.faketoken = onRequest((request, 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;
logger.log(`Grant type ${grantType}`);
let obj;
if (grantType === 'authorization_code') {
obj = {
token_type: 'bearer',
access_token: '123access',
refresh_token: '123refresh',
expires_in: secondsInDay,
};
} else if (grantType === 'refresh_token') {
obj = {
token_type: 'bearer',
access_token: '123access',
expires_in: secondsInDay,
};
}
response.status(HTTP_STATUS_OK)
.json(obj);
});
const app = smarthome();
app.onSync(async (body, headers) => {
const authorizationHeader = headers.authorization;
const accessToken = authorizationHeader.split(' ')[1];
console.log('----onSync accessToken', accessToken);
let medhaResponse;
});
Подробнее здесь: https://stackoverflow.com/questions/798 ... s-explorer
Невозможно получить журналы функций Firebase node.js в Google Cloud Logs Explorer. ⇐ Javascript
Форум по Javascript
1762941718
Anonymous
Я успешно развернул свой код node.js в умном доме с помощью Google Actions.
Я добавил устройства умного дома в приложение GoogleHome, и когда я работаю с устройством, я не получаю никаких журналов функций на странице журналов Google Cloud.
Вот часть моего кода, который я использовал для умного дома.
Я использовал как console.log, так и logger.log, и почему операторы печати не отображаются в журналах облака Google страница проводника?
'use strict';
const { onRequest } = require("firebase-functions/v2/https");
const { onValueWritten } = require("firebase-functions/v2/database");
const { smarthome } = require("actions-on-google");
const { google } = require("googleapis");
const { logger } = require("firebase-functions");
const admin = require("firebase-admin");
const axios = require("axios");
const fetch = require("node-fetch");
const util = require("util");
const serviceAccount = require("");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: ""
});
//admin.initializeApp();
const firebaseRef = admin.database().ref('/');
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/homegraph'],
});
const homegraph = google.homegraph({
version: 'v1',
auth: auth,
});
// Hardcoded user ID
const USER_ID = '102';
exports.login = onRequest((req, res) => {
if (req.method === 'GET') {
logger.log('Starting of GET ');
logger.log('Requesting login page');
res.send(`
Link this service to Google
`);
logger.log('%s',req.query.responseurl);
} else if (req.method === 'POST') {
const responseurl = decodeURIComponent(req.body.responseurl);
logger.log('__POST__START_%s',req.body.responseurl);
logger.log(`Redirect to ${responseurl}`);
return res.redirect(responseurl);
} else {
// Unsupported method
res.send(405, 'Method Not Allowed');
}
});
exports.fakeauth = onRequest((request, response) => {
const responseurl = util.format('%s?code=%s&state=%s',
decodeURIComponent(request.query.redirect_uri), 'xxxxxx',
request.query.state);
logger.log(`Set redirect as ${responseurl}`);
logger.log('Ending of FAKEAUTH');
return response.redirect(
`/login?responseurl=${encodeURIComponent(responseurl)}`);
});
exports.faketoken = onRequest((request, 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;
logger.log(`Grant type ${grantType}`);
let obj;
if (grantType === 'authorization_code') {
obj = {
token_type: 'bearer',
access_token: '123access',
refresh_token: '123refresh',
expires_in: secondsInDay,
};
} else if (grantType === 'refresh_token') {
obj = {
token_type: 'bearer',
access_token: '123access',
expires_in: secondsInDay,
};
}
response.status(HTTP_STATUS_OK)
.json(obj);
});
const app = smarthome();
app.onSync(async (body, headers) => {
const authorizationHeader = headers.authorization;
const accessToken = authorizationHeader.split(' ')[1];
console.log('----onSync accessToken', accessToken);
let medhaResponse;
});
Подробнее здесь: [url]https://stackoverflow.com/questions/79817568/unable-to-get-firebase-function-logs-of-node-js-in-google-cloud-logs-explorer[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия