既然 Lock v10 已被弃用,我该如何在我的 Electron 应用程序中启用 Auth0 登录?
How do I enable Auth0 logins in my Electron app now that Lock v10 is deprecated?
我有一个 Electron 应用程序,它会与后端 API 通信,这些 API 被保护为只接受 Auth0 授权令牌。以前可以使用 Auth0.js 的 Lock 项目,但 Electron 支持在 v10 结束,最近已弃用。
我还能如何在我的 Electron 应用程序中启用登录流程?
您可以从 NPM 下载包:
# Installing electron-auth0-login
npm install electron-auth0-login --save
# Installing peer dependencies
npm install request request-promise-native --save
初始化很简单。只需将以下内容添加到主流程代码中:
import ElectronAuth0Login from 'electron-auth0-login';
const auth = new ElectronAuth0Login({
// Get these from your Auth0 application console
auth0Audience: 'https://api.mydomain.com',
auth0ClientId: 'abc123ghiMyApp',
auth0Domain: 'my-domain.eu.auth0.com',
auth0Scopes: 'given_name profile'
});
将重定向 URL 列入白名单 https://{your-auth0-domain}/mobile.
现在,当您需要令牌时,调用 auth.getToken 并且 electron-auth0-login 将 return 内存中的令牌(如果有效),使用刷新令牌(如果启用)或启动新的 Auth0 登录流程。
可以在项目的自述文件中找到完整的详细信息:https://github.com/jbreckmckye/electron-auth0-login
我有一个 Electron 应用程序,它会与后端 API 通信,这些 API 被保护为只接受 Auth0 授权令牌。以前可以使用 Auth0.js 的 Lock 项目,但 Electron 支持在 v10 结束,最近已弃用。
我还能如何在我的 Electron 应用程序中启用登录流程?
您可以从 NPM 下载包:
# Installing electron-auth0-login
npm install electron-auth0-login --save
# Installing peer dependencies
npm install request request-promise-native --save
初始化很简单。只需将以下内容添加到主流程代码中:
import ElectronAuth0Login from 'electron-auth0-login';
const auth = new ElectronAuth0Login({
// Get these from your Auth0 application console
auth0Audience: 'https://api.mydomain.com',
auth0ClientId: 'abc123ghiMyApp',
auth0Domain: 'my-domain.eu.auth0.com',
auth0Scopes: 'given_name profile'
});
将重定向 URL 列入白名单 https://{your-auth0-domain}/mobile.
现在,当您需要令牌时,调用 auth.getToken 并且 electron-auth0-login 将 return 内存中的令牌(如果有效),使用刷新令牌(如果启用)或启动新的 Auth0 登录流程。
可以在项目的自述文件中找到完整的详细信息:https://github.com/jbreckmckye/electron-auth0-login