mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-20 06:37:48 +01:00
fix: send id_token in OAuth2 requests (#223)
This commit is contained in:
committed by
GitHub
parent
6eb16afd96
commit
eb5ef7d7d5
@@ -303,6 +303,7 @@ export const plugin: PluginDefinition = {
|
||||
const headerPrefix = stringArg(values, 'headerPrefix');
|
||||
const grantType = stringArg(values, 'grantType') as GrantType;
|
||||
const credentialsInBody = values.credentials === 'body';
|
||||
const tokenName = values.tokenName === 'id_token' ? 'id_token' : 'access_token';
|
||||
|
||||
let token: AccessToken;
|
||||
if (grantType === 'authorization_code') {
|
||||
@@ -328,7 +329,7 @@ export const plugin: PluginDefinition = {
|
||||
codeVerifier: stringArgOrNull(values, 'pkceCodeVerifier'),
|
||||
}
|
||||
: null,
|
||||
tokenName: values.tokenName === 'id_token' ? 'id_token' : 'access_token',
|
||||
tokenName: tokenName,
|
||||
});
|
||||
} else if (grantType === 'implicit') {
|
||||
const authorizationUrl = stringArg(values, 'authorizationUrl');
|
||||
@@ -342,7 +343,7 @@ export const plugin: PluginDefinition = {
|
||||
scope: stringArgOrNull(values, 'scope'),
|
||||
audience: stringArgOrNull(values, 'audience'),
|
||||
state: stringArgOrNull(values, 'state'),
|
||||
tokenName: values.tokenName === 'id_token' ? 'id_token' : 'access_token',
|
||||
tokenName: tokenName,
|
||||
});
|
||||
} else if (grantType === 'client_credentials') {
|
||||
const accessTokenUrl = stringArg(values, 'accessTokenUrl');
|
||||
@@ -374,7 +375,7 @@ export const plugin: PluginDefinition = {
|
||||
throw new Error('Invalid grant type ' + grantType);
|
||||
}
|
||||
|
||||
const headerValue = `${headerPrefix} ${token.response.access_token}`.trim();
|
||||
const headerValue = `${headerPrefix} ${token.response[tokenName]}`.trim();
|
||||
return {
|
||||
setHeaders: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user