Skip to content

Commit 174e135

Browse files
kazazespi0
authored andcommitted
fix(oauth2, auth0): add audience to requests (#222)
1 parent 604cc5d commit 174e135

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/providers/_utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ function assignDefaults (strategy, defaults) {
66
}
77

88
function addAuthorize (strategy) {
9-
// Get client_secret, client_id and token_endpoint
9+
// Get client_secret, client_id, token_endpoint and audience
1010
const clientSecret = strategy.client_secret
1111
const clientID = strategy.client_id
1212
const tokenEndpoint = strategy.token_endpoint
13+
const audience = strategy.audience
1314

1415
// IMPORTANT: remove client_secret from generated bundle
1516
delete strategy.client_secret
@@ -54,6 +55,7 @@ function addAuthorize (strategy) {
5455
grant_type: grantType,
5556
response_type: responseType,
5657
redirect_uri: redirectUri,
58+
audience: audience,
5759
code
5860
},
5961
headers: {

lib/providers/auth0.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = function auth0 (strategy) {
55
_scheme: 'oauth2',
66
authorization_endpoint: `https://${strategy.domain}/authorize`,
77
userinfo_endpoint: `https://${strategy.domain}/userinfo`,
8-
scope: ['openid', 'profile', 'email']
8+
scope: ['openid', 'profile', 'email'],
9+
audience: strategy.domain
910
})
1011
}

lib/schemes/oauth2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default class Oauth2Scheme {
7070
client_id: this.options.client_id,
7171
redirect_uri: this._redirectURI,
7272
scope: this._scope,
73+
audience: this.options.audience,
7374
state: randomString()
7475
}
7576

@@ -125,6 +126,7 @@ export default class Oauth2Scheme {
125126
client_id: this.options.client_id,
126127
redirect_uri: this._redirectURI,
127128
response_type: this.options.response_type,
129+
audience: this.options.audience,
128130
grant_type: this.options.grant_type
129131
})
130132
})

0 commit comments

Comments
 (0)