我正在使用外部 API 开发 Google home 应用程序。我需要当前用户登录并与外部 API 链接(外部 API 提供的访问/刷新令牌)。
我的做法:
- 设置 Firebase 应用程序
- google home应用程序位于functions文件夹中。
- 我会设置一个页面,用户首先使用他的 Google 帐户登录firebase.auth() https://firebase.google.com/docs/auth/web/manage-users,然后是他的外部 API 帐户(使用外部 API Oauth)。
- 然后,我将在 firebase 数据库中创建一个条目,为每个用户存储外部 API 提供的访问/刷新令牌。
这是我有点困惑和卡住的地方。我已成功设置登录页面(Google 登录,然后外部 API 登录)并将其存储在 firebase 数据库 (/users/{google_uid}) 中。
现在它已在数据库中,如何在 Google home 应用程序中设置身份验证?
谢谢你!
首先,你需要有一个项目console.developers.google.com
并激活谷歌操作API在你的项目中。然后,您应该按照以下步骤操作:
将 API 中的以下重定向 URI 列入白名单:https://oauth-redirect.googleusercontent.com/r/ https://oauth-redirect.googleusercontent.com/r/
在您的 API.AI 项目中,转到“集成”并启用“操作”
谷歌卡。
In the setting of the Actions on Google, place your project ID and
select Sign in required for the welcome intent and any other
intent the user needs credentials.
Below, you will find the OAuth2 fields, like clientID, client
secret, authorization URL and token URL. Fulfill it with the OAuth2
information of your API and Authorize the application.
授权后您可以Preview该应用程序将在您的 Google Home 设备中可用,当您第一次调用时,它将在您的 Google Home 应用程序中提供一张卡片来进行链接。如果您没有设备,可以使用网络模拟器来测试您的操作。
欲了解更多信息,请访问在谷歌上的操作 https://developers.google.com/actions/develop/identity/account-linking文档。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)