auth0js 中的授权参数
Authparams in auth0js
我需要在 auth0 中设置额外的参数以使观众 url 正常工作。在 authlock 中你可以简单地这样做:
var lock = new Auth0Lock('clientID', 'account.auth0.com', {
auth: {
params: {
audience: 'url'
}
}
});
我想我需要将代码添加到我的 authservice 中的 auth0config,但我不确定是什么以及如何:
const auth0Config = {
// needed for auth0
clientID: 'id',
// needed for auth0cordova
clientId: 'id',
domain: 'url',
callbackURL: location.href,
packageIdentifier: 'id',
};
谁能告诉我怎么做?
对于 Auth0 ionic 2 快速入门,尝试添加受众 here(以及更新范围信息):
阅读源代码,预计这会起作用,因为稍后当 cordova 库使用 auth0.js 时,它最终会调用 this code 并且应该将 baseOptions 与传入的 Options 合并。但是,由于某种原因似乎没有用。
相反,我不得不通过在此处为 Cordova library itself 中的观众添加一个额外的条目来强制使用 baseOptions,例如
function CordovaAuth(options) {
this.clientId = options.clientId;
this.domain = options.domain;
this.redirectUri = options.packageIdentifier + '://' + options.domain + '/cordova/' + options.packageIdentifier + '/callback';
this.client = new auth0.Authentication({
clientID: this.clientId,
domain: this.domain,
// just hard coded here for time being - need a check to see if present first..
audience: options.audience,
_telemetryInfo: telemetry
});
}
然后在 here instead 中通过观众 - 这与您在问题中输入的代码相同。执行上述操作确实有效,并生成具有提供范围的 JWT 访问令牌,但不清楚为什么简单地将受众添加到选项不起作用...
有趣的是 API 似乎表明它 expects audience and this line suggests the audience would be propogated and used to build the authorizeUrl
here。
已将未决问题留给 Auth0 快速入门团队进行澄清。但上述解决方案将允许您同时使用 JWT 访问令牌。您可以在 node_modules
文件夹中创建 the repo and control it that way, or just for testing go ahead and edit the source 以检查它是否适合您。
一旦我收到 Auth0 快速入门团队关于 "official" 解决方案的回复,是否应该 post 对此答案进行更新。
我需要在 auth0 中设置额外的参数以使观众 url 正常工作。在 authlock 中你可以简单地这样做:
var lock = new Auth0Lock('clientID', 'account.auth0.com', {
auth: {
params: {
audience: 'url'
}
}
});
我想我需要将代码添加到我的 authservice 中的 auth0config,但我不确定是什么以及如何:
const auth0Config = {
// needed for auth0
clientID: 'id',
// needed for auth0cordova
clientId: 'id',
domain: 'url',
callbackURL: location.href,
packageIdentifier: 'id',
};
谁能告诉我怎么做?
对于 Auth0 ionic 2 快速入门,尝试添加受众 here(以及更新范围信息):
阅读源代码,预计这会起作用,因为稍后当 cordova 库使用 auth0.js 时,它最终会调用 this code 并且应该将 baseOptions 与传入的 Options 合并。但是,由于某种原因似乎没有用。
相反,我不得不通过在此处为 Cordova library itself 中的观众添加一个额外的条目来强制使用 baseOptions,例如
function CordovaAuth(options) {
this.clientId = options.clientId;
this.domain = options.domain;
this.redirectUri = options.packageIdentifier + '://' + options.domain + '/cordova/' + options.packageIdentifier + '/callback';
this.client = new auth0.Authentication({
clientID: this.clientId,
domain: this.domain,
// just hard coded here for time being - need a check to see if present first..
audience: options.audience,
_telemetryInfo: telemetry
});
}
然后在 here instead 中通过观众 - 这与您在问题中输入的代码相同。执行上述操作确实有效,并生成具有提供范围的 JWT 访问令牌,但不清楚为什么简单地将受众添加到选项不起作用...
有趣的是 API 似乎表明它 expects audience and this line suggests the audience would be propogated and used to build the authorizeUrl
here。
已将未决问题留给 Auth0 快速入门团队进行澄清。但上述解决方案将允许您同时使用 JWT 访问令牌。您可以在 node_modules
文件夹中创建 the repo and control it that way, or just for testing go ahead and edit the source 以检查它是否适合您。
一旦我收到 Auth0 快速入门团队关于 "official" 解决方案的回复,是否应该 post 对此答案进行更新。