Skip to content

Commit 8263452

Browse files
committed
adding auth header optionally
1 parent a22518e commit 8263452

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,12 @@ export const revoke = async (
189189

190190
revocationEndpoint = openidConfig.revocation_endpoint;
191191
}
192-
let basicAuth;
192+
193+
const headers = {
194+
'Content-Type': 'application/x-www-form-urlencoded',
195+
};
193196
if (includeBasicAuthorization) {
194-
basicAuth = base64.encode(`${clientId}:${clientSecret}`);
197+
headers.Authorization = `basic ${base64.encode(`${clientId}:${clientSecret}`)}`;
195198
}
196199
/**
197200
Identity Server insists on client_id being passed in the body,
@@ -201,10 +204,7 @@ export const revoke = async (
201204
**/
202205
return await fetch(revocationEndpoint, {
203206
method: 'POST',
204-
headers: {
205-
'Content-Type': 'application/x-www-form-urlencoded',
206-
Authorization: `${includeBasicAuthorization ? `basic ${basicAuth}` : ''}`,
207-
},
207+
headers,
208208
body: `token=${tokenToRevoke}${sendClientId ? `&client_id=${clientId}` : ''}`,
209209
}).catch(error => {
210210
throw new Error('Failed to revoke token', error);

0 commit comments

Comments
 (0)