在 Ionic2 运行 浏览器离线访问中使用 Auth0 进行 Google 身份验证
Using Auth0 for Google Authentication in Ionic2 running in Browser Offline Access
我正在尝试将 Auth0 用于我的 Ionic2 测试应用程序。我正在尝试让 Google 登录在 'ionic serve' 或 'ionic run browser' 中工作。这是我的 Auth0 设置
auth0 = new Auth0({clientID: 'yyy', domain: 'xxx.auth0.com' });
lock = new Auth0Lock('yyy', 'xxx.auth0.com', {
auth: {
redirect: false,
params: {
scope: 'openid',
//scope: 'openid offline_access', // DOES NOT WORK
device:'Mobile device'
}
}
});
请求 offline_access 导致身份验证失败并出现错误
{
error: "invalid_request",
errorDescription: "device parameter must be specified",
state: "aaa-bbb"
}
尽管我提供了设备名称,但为什么还是失败了?
检查 this discussion 中的答案。
有意不提供在浏览器中设置 'device name' 以进行离线访问。
We do not recommend using this flow for web applications (running in the browser), since the browser is not a device. To prevent expiration of session in the context of a web app, is better to increase the lifetime of the JWT and then automatically refresh the token every time the user goes to the application.
我建议尝试使用设备。
ionic run <platform> --device
应该可以。
我正在尝试将 Auth0 用于我的 Ionic2 测试应用程序。我正在尝试让 Google 登录在 'ionic serve' 或 'ionic run browser' 中工作。这是我的 Auth0 设置
auth0 = new Auth0({clientID: 'yyy', domain: 'xxx.auth0.com' });
lock = new Auth0Lock('yyy', 'xxx.auth0.com', {
auth: {
redirect: false,
params: {
scope: 'openid',
//scope: 'openid offline_access', // DOES NOT WORK
device:'Mobile device'
}
}
});
请求 offline_access 导致身份验证失败并出现错误
{
error: "invalid_request",
errorDescription: "device parameter must be specified",
state: "aaa-bbb"
}
尽管我提供了设备名称,但为什么还是失败了?
检查 this discussion 中的答案。
有意不提供在浏览器中设置 'device name' 以进行离线访问。
We do not recommend using this flow for web applications (running in the browser), since the browser is not a device. To prevent expiration of session in the context of a web app, is better to increase the lifetime of the JWT and then automatically refresh the token every time the user goes to the application.
我建议尝试使用设备。
ionic run <platform> --device
应该可以。