【发布时间】:2019-11-20 10:46:32
【问题描述】:
我有 GoogleHome 的示例 (https://github.com/actions-on-google/smart-home-nodejs/blob/master/src/auth-provider.ts) 在 GCP 上运行 100%,只缺少 0Auth2 身份验证,并且 Auth0 提供的服务似乎是一个很好的解决方案,但在 TypeScript 中没有示例。
Actions on Google 配置正确,可以通过 Auth0 登录,但无法集成到示例中。
经过大量研究,我一直在兜圈子。 至少从库中导入不会失败。
import * as express from 'express'
import * as util from 'util'
import { Headers } from 'actions-on-google'
import createAuth0Client from '@auth0/auth0-spa-js';
import * as Firestore from './firestore'
/**
* A function that gets the user id from an access token.
* Replace this functionality with your own OAuth provider.
*
* @param headers HTTP request headers
* @return The user id
*/
export async function getUser(headers: Headers): Promise<string> {
const authorization = headers.authorization
const accessToken = (authorization as string).substr(7)
return await Firestore.getUserId(accessToken)
} ...
【问题讨论】:
-
你到底遇到了什么问题?
-
嗨尼克,我找到了你的 tutorial 并且无法让它工作,在线
const app = smarthome说 smarthome 不是一个功能,所以我尝试了另一种方法使用 Auth0-spa-js 库,但我不知道该怎么做,Auth0 站点中没有 TypeScript 示例。我知道我缺少很多概念,但经过一番努力,我设法让 Google Home 示例完美运行,现在我必须实现 OAuth2 服务器。 -
嗨,Dan,我在 Google Home 运行的示例中看到了这个文档:当我进入 Google 助理应用程序 -> 家庭自动化 -> “+” -> 我选择我的应用程序 -> 出现 Auth0 屏幕 -> 我登录,之后我应该收到令牌,但我在调整代码时迷路了,例如如何注册“端点”。当然,我缺乏对我的概念......
标签: typescript actions-on-google auth0 google-home