Fix oauth2 json casing

This commit is contained in:
Guilherme Werner
2024-01-09 20:59:30 -03:00
parent 2094e88e9e
commit 6e305f7bca
3 changed files with 12 additions and 12 deletions

View File

@ -17,7 +17,7 @@
"prepare": "npm run build"
},
"dependencies": {
"@tribufu/mintaka": "0.1.2",
"@tribufu/mintaka": "0.1.3",
"axios": "^1.6.3",
"camelcase-keys": "^9.1.2",
"fp-ts": "^2.16.1",

8
pnpm-lock.yaml generated
View File

@ -6,8 +6,8 @@ settings:
dependencies:
'@tribufu/mintaka':
specifier: 0.1.2
version: 0.1.2
specifier: 0.1.3
version: 0.1.3
axios:
specifier: ^1.6.3
version: 1.6.4
@ -290,8 +290,8 @@ packages:
dev: true
optional: true
/@tribufu/mintaka@0.1.2:
resolution: {integrity: sha512-S6bEYchoI/Y2K803DMUW75kW3FycQCrJO2P4e+S8w1G/7gXRm+d2cvUplZLgtGVC2/X7NYrWRs5Yw6CWmjPDGQ==}
/@tribufu/mintaka@0.1.3:
resolution: {integrity: sha512-MMv0saUpDt4MxUW5cD7y9UlOvF10Qv010dgzOkMxrh2/FmCg/KjfVviPGQLRp54IHZQWTSMdGPHX/4x/G/5CZQ==}
dependencies:
axios: 1.6.4
camelcase-keys: 9.1.2

View File

@ -103,7 +103,7 @@ export class TribufuClient extends TribufuApi {
* @param tokens
*/
private setTokensFromResponse(tokens: OAuth2TokenResponse): void {
this.setTokens(tokens.accessToken, tokens.refreshToken || null, tokens.expiresIn || null);
this.setTokens(tokens.access_token, tokens.refresh_token || null, tokens.expires_in || null);
}
/**
@ -245,7 +245,7 @@ export class TribufuClient extends TribufuApi {
const requestBody: OAuth2IntrospectionRequest = {
token: this.options.accessToken,
tokenTypeHint: "access_token",
token_type_hint: "access_token",
}
const url = `/v1/oauth2/introspect`;
@ -270,7 +270,7 @@ export class TribufuClient extends TribufuApi {
const requestBody: OAuth2IntrospectionRequest = {
token: this.options.refreshToken,
tokenTypeHint: "refresh_token",
token_type_hint: "refresh_token",
}
const url = `/v1/oauth2/revoke`;
@ -310,14 +310,14 @@ export class TribufuClient extends TribufuApi {
*/
protected async getToken(grantType: OAuth2GrantType, grantValue: string | null, subjectKey: string | null, subjectValue: string | null): Promise<OAuth2TokenResponse | null> {
const requestBody: OAuth2TokenRequest = {
grantType: grantType,
grant_type: grantType,
code: grantType === "authorization_code" ? grantValue : null,
refreshToken: grantType === "refresh_token" ? grantValue : null,
refresh_token: grantType === "refresh_token" ? grantValue : null,
username: grantType === "password" || grantType === "passkey" ? subjectValue : null,
password: grantType === "password" ? grantValue : null,
passkey: grantType === "passkey" ? grantValue : null,
clientId: this.clientId,
clientSecret: this.clientSecret,
client_id: this.clientId,
client_secret: this.clientSecret,
}
const params = subjectKey && subjectValue ? `?${subjectKey}=${subjectValue}` : "";